Troubleshooting: Google OAuth
Symptoms
Section titled “Symptoms”- After Google consent, user is redirected to login/error instead of dashboard.
- Browser shows
Authentication failedorInvalid token received. - Backend callback route appears to run, but frontend never gets valid session.
- Google OAuth screen shows
redirect_uri_mismatch.
Common causes
Section titled “Common causes”- Google OAuth redirect URI does not exactly match backend callback URL.
- Backend
GOOGLE_CALLBACK_URLis outdated or uses an old domain. - Frontend/backend URLs changed (new Koyeb or Vercel domain) but OAuth config was not updated.
- Frontend env (
VITE_GOOGLE_AUTH_URL) points to the wrong backend domain. - CORS/routing issues prevent auth callback flow from completing.
Diagnostic steps
Section titled “Diagnostic steps”- Verify backend callback URL works:
https://api.korta.click/api/v1/auth/google/callback
- Check Google Cloud OAuth client config:
- Authorized JavaScript origins includes:
https://korta.click/
- Authorized redirect URIs includes:
https://api.korta.click/api/v1/auth/google/callback
- Authorized JavaScript origins includes:
- Check backend env vars:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_CALLBACK_URL=https://api.korta.click/api/v1/auth/google/callbackFRONTEND_URL=https://korta.click/
- Check frontend env:
VITE_GOOGLE_AUTH_URL=https://api.korta.click/api/v1/auth/google
- Redeploy both services after env/config changes.
- Make all OAuth URLs exact and consistent across:
- Google Console
- Backend env
- Frontend env
- Remove stale domains from callback/origin settings.
- Ensure backend service is mounted at public path
/on Koyeb. - Ensure production frontend uses the same domain configured in Google origins.
Verification
Section titled “Verification”- Clicking “Continue with Google” opens Google consent correctly.
- After consent, user is redirected to frontend callback route and then dashboard.
- Frontend stores
accessTokenand authenticated routes load. GET /api/v1/auth/mesucceeds with Bearer token after OAuth login.