fix guide
Google sign-in redirect_uri_mismatch after deploy
Harjot · · updated
Google sign-in works in the builder's preview or on localhost. On your live domain, Google stops the sign-in with redirect_uri_mismatch.
Google only sends people back to addresses you registered on the OAuth client. Your live address isn't on that list, or the address your app sends differs from the one you registered. If you use Supabase Auth, Supabase has its own list too. Check these five in order. Each takes a few minutes in a dashboard.
1. The redirect URI isn't on the Google OAuth client
This one applies if your app talks to Google directly. In Google Cloud, open the Google Auth Platform, then Clients, and open your OAuth client. The Authorized redirect URIs list holds every address Google may send people back to.
Google's docs say the redirect URI your app sends must exactly match one of the authorized redirect URIs. The http or https scheme, the case and the trailing slash must all match. Outside localhost, redirect URIs must use https.
Copy the address your app uses on the live site and add it to the list exactly. Then save.
Test again after a short wait before you change anything else.
signs Sign-in works on localhost and fails on the live domain with redirect_uri_mismatch.
2. With Supabase, Google needs the Supabase callback
If your app signs in through Supabase Auth, Google sends people back to Supabase first, and Supabase then sends them to your app. So the Google OAuth client needs the Supabase callback URL.
In Supabase, open Authentication, then Sign In / Providers, then Google. Copy the callback URL shown there. It ends in /auth/v1/callback. In Google Cloud, paste it under Authorized redirect URIs on the OAuth client.
Supabase's Google guide also says to add your app's URL under Authorized JavaScript origins. If your app lives at https://example.com/app, add https://example.com. Remove any localhost origin before you go to production, as the guide says.
signs Your app uses supabase.auth.signInWithOAuth, and the callback URL on the Supabase Google page is missing from the Google client.
3. Site URL and Redirect URLs in Supabase
Supabase's docs say the Site URL is the default redirect when your code sets no redirectTo. They tell you to change it from http://localhost:3000 to your production URL. If it still says localhost, people land there after Google sign-in.
The same docs say the redirectTo in your code should match the Redirect URLs list. Open Authentication, then URL Configuration, and add your live address, for example https://yourapp.com/**. In the list, ** matches any sequence of characters. A single * stops at a dot or a slash.
Then check the redirectTo value in your sign-in code. If it is hardcoded to localhost, change it to your live address.
supabase.auth.signInWithOAuth({
provider: "google",
options: { redirectTo: "https://yourapp.com/welcome" },
})signs Google sign-in finishes, then you land on localhost or on the wrong page.
4. www and the bare domain are different addresses
https://www.yourapp.com and https://yourapp.com are two addresses. Because Google wants an exact match, a client that lists one fails on the other. Supabase's Redirect URLs list works the same way, entry by entry.
Add both versions in Supabase under Redirect URLs, and both under Authorized JavaScript origins in Google. With plain Google OAuth, add the redirect URI for each version too.
Vercel's docs say that if a visitor uses a domain with or without www, Vercel will attempt to redirect automatically. They recommend one primary domain with a redirect from the other. Then check that the address in the browser is the one you registered.
signs Sign-in works on one version of the address and fails on the other.
5. Preview domains
Each Vercel preview deployment has its own address. For Supabase, the docs show a Vercel setup: set the Site URL to your official URL, and add https://*-<team-or-account-slug>.vercel.app/** to Redirect URLs for deployment previews. Replace the slug with yours.
Google is stricter. Its docs say redirect URIs cannot contain wildcard characters. With plain Google OAuth, each preview address needs its own entry, or you test sign-in on one fixed address.
With Supabase, Google only needs the Supabase callback from step 2. The preview wildcard belongs in the Supabase list.
signs Sign-in works on the live domain and fails on a preview link, or the other way round.
Test it like a new user
- Wait a few minutes after any Google Cloud change, then open the live site in a new private window.
- Click the Google sign-in button and finish sign-in with a Google account that isn't yours.
- Check you land on the live domain, signed in, and not on localhost.
- Repeat on the www version and the bare domain.
- Try a preview link if you use them.
Common questions
What causes redirect_uri_mismatch after I deploy?
Your live address isn't an exact match for one registered on your OAuth client. Google checks https, letter case and the trailing slash. Your live address isn't on the list, or your app sends a different one. With Supabase Auth, register the Supabase callback URL instead.
Which redirect URI does Google need when I use Supabase Auth?
Google needs the Supabase callback URL, which ends in auth/v1/callback. Copy it from Authentication, then Sign In / Providers, then Google in Supabase, and paste it under Authorized redirect URIs on the Google OAuth client. Add your app's own address under Authorized JavaScript origins.
Why does Google sign-in work on www but not on my bare domain?
They are two different addresses, and Google wants an exact match. Add both versions under Authorized JavaScript origins in Google and under Redirect URLs in Supabase. Then pick one primary domain and redirect the other to it, so visitors always land on a registered one.
Still stuck?
Not sure this is the cause? Paste your app's link into the free scan. It lists what a visitor's browser can see, like leaked keys and exposed files, worst first. The score is free; every fix as a prompt for your builder is $9, one-time.
Want a person to look inside? See the diagnosis