Skip to content

Conversation

@mandarini
Copy link
Contributor

Summary

  • Adds AuthPKCECodeVerifierMissingError with actionable guidance for users
  • Validates code verifier presence before making the token exchange request
  • Only triggers for PKCE flow clients to maintain backward compatibility

Problem

Users calling exchangeCodeForSession() when the code verifier is missing (common when email link is opened in different browser/device, or SSR apps without cookie storage) receive an unhelpful server error: "both auth code and code verifier should be non-empty".

Solution

Detect the missing code verifier client-side and throw a helpful error:

  > PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For server-side auth, ensure you are using @supabase/ssr with cookie-based storage.

Closes #950

@github-actions github-actions bot added the auth-js Related to the auth-js library. label Dec 8, 2025
@mandarini mandarini marked this pull request as ready for review December 8, 2025 16:10
@mandarini mandarini requested review from a team as code owners December 8, 2025 16:10
@coveralls
Copy link

coveralls commented Dec 8, 2025

Coverage Status

coverage: 95.367% (+14.1%) from 81.223%
when pulling 50d9c26 on fix/auth-pkce-code-verifier-missing-error
into 139a745 on master.

@mandarini mandarini self-assigned this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth-js Related to the auth-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error on exchangeCodeForSession when setting the token key for password recovery

3 participants