Fix: set convex_jwt cookie after passkey sign-in#244
Open
david-breidert wants to merge 1 commit intoget-convex:mainfrom
Open
Fix: set convex_jwt cookie after passkey sign-in#244david-breidert wants to merge 1 commit intoget-convex:mainfrom
david-breidert wants to merge 1 commit intoget-convex:mainfrom
Conversation
The after hook that sets the `convex_jwt` cookie for server-side rendering does not match the passkey verify-authentication path. When a user signs in via passkey, the Better Auth session cookie is set by the core framework, but the Convex JWT cookie is never written because `/passkey/verify-authentication` is not included in the after hook matcher. This causes server-side auth checks (e.g. `getToken()` in SvelteKit hooks) to return `undefined`, redirecting authenticated users back to the login page. Add `/passkey/verify-authentication` to the matcher so the JWT cookie is set on passkey sign-in, consistent with all other sign-in methods.
|
@david-breidert is attempting to deploy a commit to the Convex Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
The after hook in the Convex plugin that sets the
convex_jwtcookie doesn't include/passkey/verify-authenticationin its path matcher. Every other sign-in method (/sign-in,/callback,/magic-link/verify, etc.) is covered — passkey was missed.Because of this, passkey sign-in creates a valid session and sets
better-auth.session_token, but theconvex_jwtcookie never gets written.getToken()returnsundefinedon the server side and the user gets redirected back to login.Fix
Add
ctx.path.startsWith("/passkey/verify-authentication")to the matcher. This is the only passkey endpoint that creates a new session — the others either require an existing session or don't create one.