Skip to content

Fix: set convex_jwt cookie after passkey sign-in#244

Open
david-breidert wants to merge 1 commit intoget-convex:mainfrom
david-breidert:fix/passkey-jwt-cookie
Open

Fix: set convex_jwt cookie after passkey sign-in#244
david-breidert wants to merge 1 commit intoget-convex:mainfrom
david-breidert:fix/passkey-jwt-cookie

Conversation

@david-breidert
Copy link

Problem

The after hook in the Convex plugin that sets the convex_jwt cookie doesn't include /passkey/verify-authentication in 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 the convex_jwt cookie never gets written. getToken() returns undefined on 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.

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.
@vercel
Copy link

vercel bot commented Jan 27, 2026

@david-breidert is attempting to deploy a commit to the Convex Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant