Error 400: redirect_uri_mismatch (Google sign-in)
The error
Error 400: redirect_uri_mismatch โ The redirect URI in the request does not match the ones authorized
Why it happens
The callback URL your app sends to Google isn't listed exactly (scheme, domain, path, trailing slash) in Google Cloud Console โ Credentials โ OAuth client โ Authorized redirect URIs.
How to fix it
- Copy the redirect_uri from the error details.
- Add it exactly in Google Cloud Console โ APIs & Services โ Credentials โ your OAuth client.
- For NextAuth/Auth.js it's https://YOURDOMAIN/api/auth/callback/google; set NEXTAUTH_URL/AUTH_URL to your production URL.
- Wait a few minutes for Google to propagate the change.
Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)
Google sign-in fails with redirect_uri_mismatch in production. Find where the OAuth callback URL is built, make it use the production base URL from an env var, tell me the exact redirect URI to add in Google Cloud Console, and list the env vars (e.g. AUTH_URL/NEXTAUTH_URL) to set on the host.
FAQ
Does http vs https matter?
Yes, the URI must match exactly, including scheme and trailing slash.
Can I use wildcards?
No, Google requires exact redirect URIs.
Related fixes
- Magic link / OAuth login redirects to localhost:3000
- User is logged out after page refresh
- Supabase query returns an empty array (no error)
- new row violates row-level security policy for table
Want the full checklist for this area? Get a Fix Kit ($29)
Featured slot available: reach thousands of vibe coders. Sponsor this week โ
Get one new fix a week
Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.
We only use your email to send the newsletter. Unsubscribe any time. See privacy.