You added "Sign in with Google" to your app. Clicking it shows:
Error 400: redirect_uri_mismatch
or you sign in and land on localhost, or on the wrong page.
Why it happens
The OAuth provider only sends users back to addresses you pre-registered. Any difference, even a trailing slash, fails.
- Production URL not registered. You added
http://localhost:3000in the Google console but not your live domain. - http vs https. The registered value and the real one differ.
- Wrong callback path. With Supabase, the Google console needs Supabase's callback URL (
https://<project>.supabase.co/auth/v1/callback), not your app's URL. - Supabase Site URL still set to localhost. Auth redirects fall back to the Site URL. Set it to your live domain in Authentication, URL Configuration.
- Redirect URL not on the allow list. Add your live domain and preview domains to the allowed redirect URLs.
- Preview domains. Every Vercel or Netlify preview has a new hostname that is not registered.
The unsafe fix
The quick fix for cause 6 is a wildcard like https://* or * in the allowed redirect URLs. An open redirect list lets an attacker craft a sign-in link that sends the user, with the auth token, to a site the attacker controls. Allow your exact domains, and a narrow wildcard only for your own preview pattern.
Also avoid:
- Putting the OAuth client secret in front-end code. The secret belongs on the server or in the provider's dashboard.
- Leaving the localhost URL in production settings forever. Keep dev and prod as separate OAuth clients.
The safe pattern
- List exact URLs: local, production, and your preview pattern.
- Register the provider callback in the provider console, and your app URLs in the auth service allow list.
- Test the full sign in on the live domain with a fresh private window.
An outside view
ProofForge at proofforge.live runs a free public-side scan of AI-built apps. It never signs in, so it cannot test your sign-in flow, and it will not tell you your redirect list is correct. It can show what is exposed to a visitor before login, such as secret-shaped strings in your bundle.
