Target errors:
- Google login –
302redirect loop (never completes) - GitHub login –
400 Bad Request
This guide walks you through fixing these issues for https://mustersheets.netlify.app/ or any other Netlify-hosted front-end that uses Supabase Auth.
| HTTP Code | Provider | Likely Meaning |
|---|---|---|
| 302 | OAuth flow starts but Google redirects back to an unauthorised or mismatched URL, so Supabase immediately redirects again. Infinite loop. | |
| 400 | GitHub | GitHub rejected the authorization request. Most common causes: wrong Client ID/Secret or callback URL not whitelisted in the GitHub OAuth App or Supabase provider settings. |
- Supabase Dashboard → Project → Auth → Settings → External OAuth Providers
- Google & GitHub toggled ON
- Redirect URLs contain exactly
(include trailing slash where shown; each on its own line)
https://mustersheets.netlify.app/ https://mustersheets.netlify.app/auth/v1/callback
- Google Cloud Console
- OAuth 2.0 Client → Authorized redirect URIs list must match those above.
- GitHub Developer Settings → OAuth Apps
- Authorization callback URL list includes
https://mustersheets.netlify.app/auth/v1/callback
- Authorization callback URL list includes
- Supabase Dashboard → Auth → Settings → General → Site URL
- Must be
https://mustersheets.netlify.app(nolocalhost, no trailing slash).
- Must be
- Netlify Environment Variables
Redeploy if you changed any value.
VITE_SUPABASE_URL = https://<project>.supabase.co VITE_SUPABASE_ANON_KEY = <anon key> - Clear browser cache or use Incognito, then retest.
- Supabase → Auth → Settings → Google.
- Copy Client ID and Client Secret from Google Cloud Console.
- Redirect URLs (each on new line):
https://mustersheets.netlify.app/ https://mustersheets.netlify.app/auth/v1/callback - Click Save.
- API & Services → OAuth-consent → Publishing status = In Production.
- OAuth 2.0 Credentials → your Web client → Authorized redirect URIs → add the exact URLs above.
- Click Save.
- Supabase → Auth → Settings → GitHub.
- Paste Client ID and Secret from GitHub OAuth App.
- Same Redirect URLs list as in §3.1.
- Save.
- GitHub → Settings → Developer settings → OAuth Apps → your app.
- Authorization callback URL → set to
https://mustersheets.netlify.app/auth/v1/callback - Update application.
If Google login sends users to http://localhost:3000 after deployment, your Supabase Site URL is still pointing to localhost.
- Supabase → Auth → Settings → General.
- Locate Site URL.
- Change it to your production domain exactly:
No trailing slash, no
https://mustersheets.netlify.apphttp, nolocalhost. - Click Save. Supabase now uses this domain when it cannot infer
redirect_to. - Retest Google login. The redirect should now return to Netlify, not localhost.
| Step | Expected Result |
|---|---|
1. git push → Netlify build. |
Build succeeds, environment vars present. |
| 2. Open Incognito → press Continue with Google. | Google prompt appears, then redirects back to /. User is signed in (Supabase session token in localStorage). |
| 3. Sign out → press Continue with GitHub. | GitHub authorises, redirects back, user signed in. |
| 4. Supabase Dashboard → Auth → Users. | New user rows appear with identities google / github. |
| Symptom | Fix |
|---|---|
| Google spins forever, network shows 302 → 302 → 302 | Redirect URL mismatch in Google Cloud or Supabase provider settings. |
| Google redirects to localhost:3000 | Site URL in Supabase is still http://localhost:3000. Update to Netlify domain (see §3.5). |
GitHub 400 Bad Request immediately |
Callback URL missing in GitHub OAuth App. |
| Works locally but not on Netlify | Forgot to add Netlify URL (including https://) in provider settings. |
| GitHub works in dev but not prod | Using different Supabase projects/keys between environments; confirm VITE_SUPABASE_URL & ANON_KEY. |
403 on /auth/v1/logout |
Stale or corrupted cookies; clear site data & retry. |
- Supabase Logs → filter by
path like '/auth/v1/authorize%'. - Look for
error=redirect_uri_mismatch(Google) orredirect_uriparameter rejected (GitHub). - Confirm the
redirect_toquery param generated by your front-end matches the URLs saved in provider dashboards. - Remember Netlify deploy previews (
https://deploy-preview-###--mustersheets.netlify.app) need to be whitelisted separately if you test there.
- Regenerate Client Secret (Google/GitHub) and update Supabase.
- Ensure your Supabase project is not paused (Billing → usage).
- Ask Supabase support with request ID from
x-request-idresponse header.
Happy authenticating!