Google login sends you back to localhost (or “redirect_uri_mismatch”)

You'll see:
  • 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

  1. 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
  2. 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
  3. 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 }
    })
  4. Using Firebase or Clerk instead?

    See the Firebase unauthorized-domain and Clerk development-keys guides.

Common with:

Related fixes