Open
Conversation
|
@skyfallwastaken is attempting to deploy a commit to the Karo Roghzai's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds Cloudflare Turnstile-based bot protection by introducing a short-lived, HMAC-signed “session token” that must be presented to access protected AI endpoints.
Changes:
- Added server-side session token signing/verification and a
/api/sessionexchange endpoint backed by Turnstilesiteverify. - Introduced server middleware to block bot user agents and require
x-session-tokenfor/api/aiand/api/embeddings. - Added client composables to solve Turnstile, cache/refresh the session token, and attach it to API requests.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| server/utils/session.js | Implements HMAC-signed session tokens with expiry validation. |
| server/middleware/guard.js | Enforces bot detection + session-token requirement on protected API routes. |
| server/api/session.post.js | Verifies Turnstile token and issues short-lived signed session tokens. |
| nuxt.config.ts | Adds runtime config entries for Turnstile keys and sessionSecret. |
| app/composables/useTurnstile.js | Loads Turnstile script and solves an invisible widget to obtain a token. |
| app/composables/useSession.js | Exchanges Turnstile token for session token; caches in memory/localStorage with refresh. |
| app/composables/storeConversations.js | Adds x-session-token to background title-generation requests. |
| app/composables/message.js | Adds x-session-token to /api/ai requests. |
| app/composables/memory.js | Adds x-session-token to /api/embeddings requests. |
| package.json | Bumps version and adds isbot dependency. |
| package-lock.json | Adds isbot, but also includes metadata/peer-flag churn needing cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Cloudflare Turnstile integration for bot protection.
Configuration
Set the following environment variables:
NUXT_TURNSTILE_SECRET_KEYNUXT_PUBLIC_TURNSTILE_SITE_KEYNUXT_SESSION_SECRETYou can get your Turnstile site key and secret key from the Cloudflare dashboard.