- After signing in with Google you land on http://localhost:3000
- Error 400: redirect_uri_mismatch
- Login works on the builder's preview URL but not on your domain
Why it happens
Two lists must include your live URL: your auth provider's allowed redirect URLs (Supabase's Site URL defaults to http://localhost:3000) and, for Google, the Authorized redirect URI in Google Cloud, which must be Supabase's callback URL.
How to fix it
-
Supabase: set Site URL and Redirect URLs
Dashboard → Authentication → URL Configuration. Set Site URL to your production domain and add every domain you use to Redirect URLs. Wildcards are supported for preview deploys.
Site URL: https://yourdomain.com Redirect URLs: https://yourdomain.com/** https://**--my_org.netlify.app/** # Netlify previews -
Google Cloud: authorised redirect URI
In your OAuth client, the Authorized redirect URI is Supabase's callback, not your site:
https://<project-ref>.supabase.co/auth/v1/callback -
Pass redirectTo in code
When starting sign-in, set redirectTo to window.location.origin (or your callback route) so it works on every domain listed above.
await supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: window.location.origin } }) -
Using Firebase or Clerk instead?
See the Firebase unauthorized-domain and Clerk development-keys guides.