Error 400: redirect_uri_mismatch on Google sign-in (or "The JavaScript origin in the request does not match")
Short answer: Google only sends people back to addresses you listed in advance, and the one your app just asked for isn't on the list. Find the exact redirect_uri your sign-in request uses, then add that address, character for character, under Authorized redirect URIs on your OAuth client in the Google Cloud console. Google's docs say the scheme (http or https), the letter case and the trailing slash all have to match, and wildcards aren't allowed.
The fix
- Find the exact
redirect_uriyour app sends: open a private window, click the Google button, and decode theredirect_uri=value from Google's address bar (%3Ais:,%2Fis/). - Add it exactly under Authorized redirect URIs on the Web application OAuth client whose Client ID your app uses. Scheme, letter case and trailing slash must match; keep any older address people still use.
- Add the origin under Authorized JavaScript origins if needed (scheme and domain only, like
https://yourdomain.com), especially when Google's button or popup runs in your page. - Save, wait for Google's changes to take effect (Google's help says 5 minutes to a few hours), then retest in a fresh private window on the live domain.
Signs this is your problem
- Clicking "Continue with Google" opens a Google page that says Error 400: redirect_uri_mismatch instead of the account picker.
- It started after you moved to a custom domain, renamed a project, turned on a custom domain for your backend, or deployed to a new host.
- It works on one address (say, your preview link or
localhost) but not another.
If Google sign-in finishes fine but people then land on the old preview link or localhost, that's a different problem with where your auth service sends people afterwards. See Login broke after I added my custom domain.
Error 400: redirect_uri_mismatch: "The redirect_uri passed in the authorization request does not match an authorized redirect URI"
That's how Google's OAuth error reference describes redirect_uri_mismatch: the redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID, so review Authorized redirect URIs on the Google Cloud console Clients page. Google's docs add that the scheme (http or https), letter case and trailing slash must all match. If the address in the error is right but still rejected, check you're editing the client whose Client ID your app actually uses. Google's reference also notes the error can come from the old out-of-band (OOB) flow, which is no longer supported.
Why it happens
When your app starts Google sign-in, it tells Google where to send the person back, in a redirect_uri parameter on the sign-in link. Google compares that address with the list saved on your OAuth client. Google's OAuth docs say the value must exactly match one of the authorized redirect URIs for that client, or you get redirect_uri_mismatch. So https://yourdomain.com/callback and https://yourdomain.com/callback/ count as two different addresses, and so do www and non-www.
Step 1: find the address your app actually sends
- Open your app in a private window and click the Google button.
- Look at the address bar on Google's page. The long link contains
redirect_uri=followed by an encoded address, where%3Ais:and%2Fis/. - Write that address down exactly as it is. That's the one Google needs on its list.
Which address you'll see depends on what handles sign-in:
- Supabase Auth: your project's callback,
https://<project-ref>.supabase.co/auth/v1/callback(shown on the Google provider page in the Supabase dashboard). Moving your app to a new domain doesn't change it. But if you turn on a custom domain or vanity subdomain for the Supabase project itself, Supabase's docs say OAuth flows start advertising the new domain as the callback, so you need to add, for example,https://api.yourdomain.com/auth/v1/callbackin Google too, alongside the old one. - Firebase Authentication: the auth handler,
https://<project>.firebaseapp.com/__/auth/handlerby default. If you setauthDomainto your own domain, Firebase's docs say to addhttps://<your-domain>/__/auth/handlerto the provider's redirect URIs; the/__/auth/handlerending matters. - Auth.js (NextAuth) on Next.js:
https://yourdomain.com/api/auth/callback/google, per the Auth.js Google provider docs. - Your own code: whatever your server passes as
redirect_uri. Check it's built from your live domain, not a preview address orlocalhost.
Step 2: add it to your Google OAuth client
- In the Google Cloud console, open the project your app uses, then the Clients page of the Google Auth Platform (older screens call it Credentials). Open the Web application client whose Client ID your app uses. Projects often have more than one, so match the ID.
- Under Authorized redirect URIs, add the exact address from step 1. Keep the old one if anyone still signs in there, such as your preview link while you test.
- Under Authorized JavaScript origins, add your live site, like
https://yourdomain.com. Supabase's Google guide asks for this too. It's just the scheme and domain: an app athttps://yourdomain.com/appuseshttps://yourdomain.com. - Save, then try again in a fresh private window. If it still fails, compare the two addresses letter by letter: a missing
sinhttps, awww, or a trailing slash is usually the difference.
"The JavaScript origin in the request does not match the ones authorized for the OAuth client"
Some apps get a longer message on the same Google error page: "The JavaScript origin in the request, https://..., does not match the ones authorized for the OAuth client." This one isn't about the return address. It means the page that started sign-in (its origin: scheme, domain and port) isn't on your client's Authorized JavaScript origins list. You'll usually see it when Google's sign-in button or popup runs right in your web page instead of going through your server or Supabase. Google's docs call this origin_mismatch and say the scheme, domain and port must match an authorized origin.
- Copy the address shown in the error after "The JavaScript origin in the request,". That's the exact origin Google saw.
- On the same OAuth client (match the Client ID), add it under Authorized JavaScript origins as scheme and domain only, like
https://yourdomain.com. Google's rules don't allow a path, query or#part, so leave off/appand any trailing slash. - If people can reach both
https://yourdomain.comandhttps://www.yourdomain.com, add both; they are different origins. For local testing, Google's setup guide says to add bothhttp://localhostandhttp://localhost:<port>, such ashttp://localhost:5173. - Save, wait a few minutes, then retry in a fresh private window. Google's help says changes to these settings can take 5 minutes to a few hours to take effect, so an error right after saving doesn't mean the fix was wrong.
Rules Google enforces on these addresses
Google's docs list validation rules for redirect URIs. The ones that trip people up most:
- They must use
https. Onlylocalhostaddresses may use plainhttp. - No wildcards (
*), so you can't cover every preview link with one entry. Add each address you really use. - No raw IP addresses (except localhost), and no
#fragment.
Built with Lovable, Bolt, Cursor, or by hand?
You can paste this to your AI builder:
Google sign-in fails with "Error 400: redirect_uri_mismatch" on my live domain. Please:
1. Tell me exactly which redirect_uri my app sends to Google in production, and where in the code or auth settings it comes from.
2. Make sure it's built from my live domain, not a preview URL or localhost.
3. List every redirect URI and JavaScript origin I need to add to my Google OAuth client.
Don't change any client secrets or print them.
Then add those addresses yourself in the Google Cloud console. Your builder can't change Google's settings for you.
Check it like a new customer
In a private window on your real domain, sign in with a Google account that has never used your app, then log out and sign in again. Try the www version too if people can reach it. Test on the address customers use, not just the preview.
Common questions
What does "Error 400: redirect_uri_mismatch" mean?
Google's OAuth error reference describes redirect_uri_mismatch as: the redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID. In plain words, Google only sends people back to addresses you listed in advance, and the one your app asked for isn't on the list. Fix it under Authorized redirect URIs on that client's page in the Google Cloud console (Clients page), matching the address exactly.
Do scheme, letter case and a trailing slash have to match?
Yes. Google's docs say the scheme (http or https), the letter case and the trailing slash all have to match, and wildcards aren't allowed. So https://yourdomain.com/callback and https://yourdomain.com/callback/ count as two different addresses, and so do www and non-www.
What does "The JavaScript origin in the request does not match the ones authorized for the OAuth client" mean?
The page that started Google sign-in (its origin: scheme, domain and port) isn't on your OAuth client's Authorized JavaScript origins list. Google's error reference calls this origin_mismatch: the scheme, domain and/or port of the JavaScript originating the request may not match an authorized JavaScript origin, so review Authorized JavaScript origins on the Google Cloud console Clients page. It's different from redirect_uri_mismatch, which is about the return address under Authorized redirect URIs. Origins can't contain a path, query or fragment, so add scheme and domain only, like https://yourdomain.com.
With Google via Supabase, is the Google redirect URI my app's Site URL?
No. With Supabase Auth, Google needs your project's callback under Authorized redirect URIs: https://<project-ref>.supabase.co/auth/v1/callback (shown on the Google provider page). Moving your app to a new domain doesn't change that callback. Where people land afterwards is controlled by Supabase Site URL and Redirect URLs. If you turn on a custom domain for the Supabase project itself, add that custom callback in Google too alongside the old one, and add your app URL under Authorized JavaScript origins.
How AppFirstAid helps
Our free check reads your live site's public code from the outside. If a sign-in or return address in that code, including a redirect_uri, points at localhost or a preview or test host instead of your live domain, the report flags it. It can't see your Google Cloud console, so it can't tell you what's on your authorized list. A journey test goes further: a real browser signs up, opens the confirmation email, logs in and tries checkout on your live site, and shows you the step that broke.
Sources, read October 29, 2026: Google Identity docs "Using OAuth 2.0 for Web Server Applications" (redirect_uri must exactly match an authorized redirect URI or you get redirect_uri_mismatch; scheme, case and trailing slash must match; redirect URI validation rules: https except localhost, no raw IPs, no wildcards, no fragments); Supabase docs "Login with Google" (add the project's callback URL under Authorized redirect URIs, app URL under Authorized JavaScript origins); Supabase docs "Custom Domains" (OAuth flows advertise the custom domain as the callback; add it in each provider's console alongside the project URL); Firebase docs "Best practices for using signInWithRedirect" (https://<your-domain>/__/auth/handler as a redirect URI when authDomain changes); Auth.js docs "Google provider" (callback /api/auth/callback/google on Next.js). These tools may change these details.
Sources for the JavaScript origin section, read November 2, 2026: Google Identity docs "OAuth 2.0 for Client-side Web Applications" (origin_mismatch: scheme, domain and/or port must match an authorized JavaScript origin; origins can't contain a path, query or fragment, must use https except localhost); Google Identity docs "Setup" for Sign In With Google (origin is scheme and hostname only; add both http://localhost and http://localhost:<port_number> for local tests); Google Cloud Help "Manage OAuth Clients" (changes may take 5 minutes to a few hours to take effect). Google may change these details.
Sources for the error-message wording, read November 15, 2026: the authorization-error tables in Google Identity docs "Using OAuth 2.0 for Web Server Applications" and "OAuth 2.0 for Client-side Web Applications" (redirect_uri_mismatch: the redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID, review Authorized redirect URIs on the Cloud Console Clients page, may also refer to the deprecated OOB flow; origin_mismatch: scheme, domain and/or port of the JavaScript originating the request may not match an authorized JavaScript origin, review Authorized JavaScript origins).
Check your live app in under a minute
AppFirstAid's free check looks at your live site from the outside: leaked keys, files left in public, safety settings, and whether your sign-up, login and checkout pages open. No signup. Journey tests go further: a simulated first-time user (a real browser) signs up, opens your email, logs in and tries checkout, and shows you the step that broke. Your first journey test is free.
Run the free checkSettings move around as these tools update. If a menu name has changed, look for the same words nearby. Spotted something out of date? Tell us.
More guides
- Stripe says they paid, but nothing unlocked in my vibe-coded app
- Login broke after I added my custom domain (Supabase redirect URLs)
- What built-in security scans miss in AI-built apps
- Supabase confirmation emails not arriving for new users
- Supabase "permission denied for table" (error 42501) on a new table: why it happens and the fix
- My app works in preview but breaks in production (environment variables differ)
- Stripe webhook fails with 401 on a Supabase Edge Function
- Lovable app launch checklist: how to test your Lovable app before launch (sign-up, email, login, checkout)
- Bolt app shows a database permissions error on a new table (tables private by default since Oct 30, 2026)