Skip to content

Google sign-in fails after deploy: redirect_uri_mismatch, or it sends you to localhost

Google sign-in worked on localhost and fails on the live site with redirect_uri_mismatch, or it drops people on localhost. How to check the Google callback, the Supabase Site URL and Redirect URLs, redirectTo, preview hosts, Testing mode, and exact URL mismatches.

You shipped an app with Lovable, Bolt, Replit, Cursor or v0, and Google sign-in worked on your machine. After deploy, Google shows redirect_uri_mismatch, or the account picker succeeds and the browser lands on localhost. Google and your auth provider keep separate lists, and the saved URLs still describe the machine you built on. On the live site, in a private window, fix the first check that is wrong.

Two redirects, two lists

With Supabase Auth, sign-in takes two hops.

Google sends the person to your project's callback. That URL belongs under Authorized redirect URIs on the Google client. For a hosted project it has this shape. Copy it from the Google provider page in the Supabase dashboard so the project ref is exact:

https://<project-ref>.supabase.co/auth/v1/callback

Supabase's Google guide says to add that callback there. The local CLI stack uses http://127.0.0.1:54321/auth/v1/callback. Leave the local URL off the production client.

Supabase then sends the person to your app: the redirectTo your code passed, when that exact URL is in Redirect URLs. With no allowed redirectTo, Supabase uses the Site URL, which defaults to http://localhost:3000.

redirect_uri_mismatch is the Google hop. Landing on localhost or a preview is the hop back to your app. With another provider, Google must allow the callback that provider shows, and that provider must allow your domain.

The Google client is missing the callback

Open Google Cloud, then Google Auth Platform, then Clients, and open the Web application client. The Supabase callback should be a row under Authorized redirect URIs. Supabase shows the same value on Authentication, then Providers, then Google.

If the menu still says APIs & Services, then Credentials, it is the same client and the same field.

Google compares the redirect_uri on the request with that list, character by character. Scheme, host, path, case, and a trailing slash all count. Google's client help says a saved change can take from five minutes to a few hours to apply. The error page prints the redirect_uri Google received. That exact string has to be in the list.

Generated apps often register http://localhost:3000, or the app's own /auth/callback, and never the Supabase URL. Google then stops the request before Supabase sees it. Redirect URIs also reject wildcards, so a pattern for every vercel.app or lovable.app host cannot go here. Google still returns to the Supabase callback when sign-in started on a preview. Those hosts belong on the Supabase allow list.

Site URL is still localhost, or the live domain is not allow-listed

In Supabase open Authentication, then URL Configuration.

Site URL is the fallback when your code passes no redirect. Change http://localhost:3000 to the live origin, with https and without a port, a path, or a preview host: https://yourapp.com.

Redirect URLs is the allow list for redirectTo and emailRedirectTo. If the URL your code sends is missing, Supabase ignores it and people land on the Site URL. That is how a sign-in Google already accepted still opens localhost.

Add the return page, and every host people sign in from:

  • The production domain you chose.
  • The other spelling, if both www and the bare domain answer. Pick one host, redirect the other to it, and use that origin here and in your emails. The logged-out symptom is in Logged in on www, logged out without it.
  • Preview hosts you still use. Supabase allows wildcards for previews and recommends an exact production path. From their redirect docs:
https://yourapp.com/auth/callback
https://*-.vercel.app/**
http://localhost:3000/**

A single-segment wildcard does not cross . or /, so it misses a deeper path and a trailing slash. A double star crosses segments. Add the exact lovable.app origin you sign in on, too. When the failure is a password-reset email instead of the Google button, the same allow list is covered in Password reset link opens localhost, or says it is invalid or expired.

redirectTo or emailRedirectTo still points at localhost

Search for signInWithOAuth, redirectTo, and emailRedirectTo.

No redirectTo means the Site URL. A hardcoded localhost always asks to return there:

await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    redirectTo: 'http://localhost:3000/auth/callback',
  },
})

Use the origin in the address bar, and a path you allow-listed:

await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    redirectTo: `${window.location.origin}/auth/callback`,
  },
})

On a lovable.app or vercel.app preview, window.location.origin is that preview. Supabase drops it when the preview is missing from Redirect URLs, and the Site URL is used instead. window.location.href also includes the path and query, so the allow-list entry has to match the whole string.

On the server, build the URL from the public site origin in the environment. A production value of http://localhost:3000 sends every sign-in there. Point emailRedirectTo at that same public origin for confirmation and magic-link mail. If /auth/callback 404s only on the live host, or a secret never made it into production, see Login works in the Bolt or Replit preview but breaks on the live site: 7 checks.

Custom domain, vercel.app, and lovable.app

Attaching a custom domain leaves Google's callback on https://<project-ref>.supabase.co/auth/v1/callback. The app URL https://yourapp.com/auth/callback stays on the Supabase list.

Update the second hop: Site URL, Redirect URLs, redirectTo, and the production origin. Entries that still name the vercel.app or lovable.app host send people to the preview, or to the Site URL when that preview is missing from the allow list. Keep a preview entry only while you sign in there.

The consent screen is still in Testing

A testing block is a different page from redirect_uri_mismatch. In Google Cloud open Google Auth Platform, then Audience.

Publishing status starts as Testing, and Test users is who may continue. Your account is usually on that list, which is why it works for you.

Google's audience docs say Testing limits sign-in to those users, up to 100, when the app asks for scopes beyond name, email, and profile (openid, email, profile). Inside that set, including a basic Sign in with Google, other accounts can still sign in during Testing, and those grants do not expire after seven days. Drive, Gmail, Calendar, and any other extra scope remove the exception.

Select Publish app and the status becomes In production. Google may require verification before the name and logo show, and before sensitive or restricted scopes can be authorized. Extra test users leave the app in Testing.

Trailing slash, and http versus https

When the lists look right, compare the strings.

  • Authorized redirect URIs must match the redirect_uri on the error page: scheme, host, path, and trailing slash.
  • Site URL should be https://yourapp.com. http://yourapp.com, a trailing slash, and www are different values unless you chose that host.
  • Each Redirect URLs row has to match the redirectTo the code sends, including a slash at the end of the path.
  • The client ID on Supabase's Google provider has to be this Web client. An ID from another Google project checks a different allow list.

How to test like a real user

The browser you built in hides this. You are already signed into Google, you are a test user, and a tab may still be on localhost.

  1. Open a private window on the production URL.
  2. Use a Google account that is absent from Test users and that you did not use while building.
  3. On a phone, open that URL in Safari or Chrome. Inside Instagram, TikTok, or another app's browser, Google sign-in fails for a different reason: Google login works for you, not for people coming from Instagram.
  4. On the Google screen, redirect_uri should be the Supabase callback, with https, and with a trailing slash only if you saved one.
  5. After you pick the account, you should be on the live host. Reload and stay signed in.
  6. If both www and the bare domain answer, repeat from the other host.

Repeat after the next AI edit. Generated code often writes localhost back into redirectTo while the homepage still returns 200.

Paste the live login URL into the free check before you click Google. FunnelSitter opens that page in a real browser and reports the HTTP status, console errors, broken links, unfinished buttons, and load time, with a screenshot. The check stops there, so the steps above are what prove sign-in.