Before: OAuth was initiated from backend API endpoint
- Problem: Code verifier couldn't be stored properly
- Result: Implicit flow with
#access_token=...
After: OAuth initiated from frontend Supabase client
- Solution: Client has proper storage for PKCE code verifier
- Expected: PKCE flow with
?code=...
-
client/src/pages/login.tsx
- Now uses
supabase.auth.signInWithOAuth()directly - PKCE code verifier stored in sessionStorage automatically
- Now uses
-
client/src/pages/register.tsx
- Same update for consistency
npm run build:frontend
# Then deploy to Vercelnpm run dev- Open browser DevTools (F12)
- Go to Network tab
- Click "Sign in with Google"
- Watch for the authorization URL - should contain:
code_challenge=...code_challenge_method=S256
- After Google auth, check redirect URL:
- ✅ Should be:
/auth-callback?code=ABC123... - ❌ NOT:
/auth-callback#access_token=...
- ✅ Should be:
- Check sessionStorage:
- Should contain:
supabase-pkce-code-verifier - Should NOT contain raw access tokens
- Should contain:
- Client generates
code_verifier(random string) - Client computes
code_challenge = SHA256(code_verifier) - Stores
code_verifierin sessionStorage - Redirects to Google with
code_challenge - Google redirects back with
?code=... - Client calls
exchangeCodeForSession(code)with storedcode_verifier - Supabase validates and returns tokens
- Supabase client (v2.58.0) has built-in PKCE support
flowType: 'pkce'in client config enables this- Client-side storage allows proper code verifier handling
- No server-side changes needed for PKCE