Skip to content

Fix: Set accessToken cookie after Firebase authentication#184

Open
railway-app[bot] wants to merge 1 commit into
railway-deploymentfrom
railway/code-change-2mCz4V
Open

Fix: Set accessToken cookie after Firebase authentication#184
railway-app[bot] wants to merge 1 commit into
railway-deploymentfrom
railway/code-change-2mCz4V

Conversation

@railway-app

@railway-app railway-app Bot commented Apr 10, 2026

Copy link
Copy Markdown

Problem

After a successful signInWithRedirect login, handleRedirectResult in AuthContext.tsx retrieved the Firebase user but never extracted or stored the ID token as a cookie. The backend middleware (server/src/middleware.ts) checks req.cookies.accessToken on every authenticated request, so all post-login API calls immediately failed with "@verifytoken invalid access token".

Solution

Added result.user.getIdToken() immediately after confirming a valid redirect result, then called setCookie({ key: cookieKeys.ACCESS_TOKEN, value: idToken }) to persist the token before any backend requests are made. Also imported cookieKeys and setCookie from ../utils/auth/cookie, matching the same pattern already used in refreshToken() in firebase.ts.

Changes

  • Modified client/src/contexts/AuthContext.tsx

Generated by Railway


Summary by cubic

Store the ID token as an accessToken cookie right after Firebase redirect sign-in so authenticated API calls work. Fixes post-login requests failing with "@verifytoken invalid access token".

Written for commit 81b6c36. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@Satchel05 Satchel05 closed this Apr 10, 2026
@Satchel05 Satchel05 reopened this Apr 10, 2026
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