# Sign in with Google works locally and fails in production

> “Error 400: redirect_uri_mismatch” is what new users see when the Google sign-in was only set up for localhost. A test presses the button and checks where it lands.

By Jason Nguyen, Founder, Testsy. Published 2026-11-21. https://testsy.dev/blog/sign-in-with-google-works-locally-fails-in-production/

## The button that only works for you

"Continue with Google" works perfectly on your laptop. You deploy, a stranger presses it, and Google shows them a page that says **Access blocked: This app's request is invalid. Error 400: redirect_uri_mismatch**.

The forums of every platform an app gets built on have the same thread:

- On Vercel's community: sign-in [works locally and fails in production](https://community.vercel.com/t/vercel-deployment-issue-with-google-oauth/12993); another builder made a new client ID for production and [got redirect_uri_mismatch](https://community.vercel.com/t/google-oauth-2-0-issue/2499); a third got "The OAuth client was not found" ([invalid_client](https://community.vercel.com/t/issue-with-environment-variables-that-are-correctly-set/2207)).
- On Bubble's forum: Google sign-in [works in development, not in the live version](https://forum.bubble.io/t/google-oauth-error-400-redirect-uri-mismatch-for-the-domain-itself/237312).
- With Supabase on Vercel, preview deployments [redirect back to production](https://community.vercel.com/t/google-oauth-redirect-url-with-vercel-preview-urls-supabase/6345) after signing in instead of to the preview.
- Lovable's own FAQ has a page on [redirect URI mismatches](https://lovable.dev/faq/authentication/sso/redirect-uri-mismatch): the callback URL in Google Cloud Console or Supabase must match the one the app sends, full path included.

Google's rule is strict: the address your app sends must match one you registered exactly, down to `https`, the case and a trailing slash. Development uses `localhost`, production uses your domain, and each needs its own entry in Google Cloud Console and in your auth provider's allowed redirect list (in Supabase, **Authentication → URL Configuration**).

## Why you never see it

You signed in with Google once, during development, and your browser remembers. Every later test of yours either skips the button or runs on `localhost`. Your coding agent cannot see Google Cloud Console. The only check that finds it is pressing the button on the deployed site.

## The test

A test cannot (and should not) sign in to a real Google account. It does not need to. Most of these failures happen **before** the Google sign-in box appears, on Google's error page, so the test checks where the button lands:

```text
Open the sign-in page. Press the button to continue or sign in with
Google. Check the page that opens is Google's own sign-in page (its
address is on accounts.google.com) and shows a box for an email
address or phone number. Check it does not show an error such as
"Error 400: redirect_uri_mismatch", "Access blocked" or
"invalid_client". Record the name of the app or site Google says
you are continuing to. Do not type anything on Google's page.
```

The recorded name catches a quieter mistake too: a production site that sends people to the development project's consent screen, with its old name.

Run it against production and against each new domain, after every change to your auth settings and on a [nightly schedule](https://testsy.dev/blog/run-tests-against-production-every-night/).

We have not published a run of this test yet: our first attempt, against our own sign-in page, did not finish because of a problem on our side, and was not counted. The test text above is the one we used.

## Test the rest of sign-in with an account of your own

The part after Google's page (your callback, the session, the redirect into the app) needs a signed-in account, and a test should not hold a real Google login. Keep an email-and-password test account for that, stored as a [sign-in account](https://testsy.dev/docs/sign-in-accounts/), and test the same post-sign-in path with it: [Test that sign-in survives a reload](https://testsy.dev/blog/test-that-sign-in-survives-a-reload/).

The email-link version of the same mistake, links that point at `localhost`, has [its own post](https://testsy.dev/blog/sign-up-email-links-to-localhost/).

This post is part of [Testing an app you built with AI](https://testsy.dev/blog/test-an-app-you-built-with-ai/).
