published fresh until

Google login works locally but fails with redirect_uri_mismatch live

Summary As of October 2026, Google's docs say the redirect_uri your app sends must exactly match an authorized one in the Cloud Console: scheme, case and trailing slash included, no wildcards, HTTPS except localhost. In Auth.js register /api/auth/callback/<provider> on the real domain; behind a proxy set AUTH_TRUST_HOST.

Not for choosing an auth library

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The symptom

Sign-in with Google (or GitHub) worked on http://localhost:3000. After deploying you get "Error 400: redirect_uri_mismatch", or the provider sends you back to localhost.

What the error means

Google's OAuth docs: the error appears when the redirect_uri in your authorization request does not match an authorized redirect URI for your client ID. It must "exactly match" one of them, and the docs call out scheme (http or https), letter case and trailing slash. Authorized URIs are set in the Google Cloud Console clients page. Rules from the same page: HTTPS is required except for localhost, no raw IP hosts (except localhost), no wildcards, no fragments or userinfo, no path traversal, and the top-level domain must be on the public suffix list.

Checklist

1. Register the production URL in addition to localhost, not instead of it. Typical value for Next.js with Auth.js: https://yourdomain.com/api/auth/callback/google. (Auth.js deployment docs give /api/auth/callback/[provider] for Next.js and /auth/callback/[provider] for other frameworks.) 2. Print the redirect_uri your app actually sends in production (browser address bar of the Google error page, or the request URL) and compare it character by character with the console entry. Common differences: http vs https, www vs bare domain, trailing slash, wrong port. 3. Check what host the app thinks it has. Auth.js v5 infers the host from request headers, so AUTH_URL is mostly unnecessary; behind a reverse proxy or in Docker set AUTH_TRUST_HOST=true (or trustHost: true). It is inferred automatically on Vercel and Cloudflare Pages. If the redirect shows http or an internal host, the proxy headers are the usual cause (my inference, not stated for every setup). 4. Preview deployments can use changing URLs, and provider limits may prevent registering each URL; Auth.js documents AUTH_REDIRECT_PROXY_URL pointing at a stable auth URL, registered at the provider, with the same AUTH_SECRET on both. 5. Wait and retry. Consoles can take a while to apply changes (Google's official client-management help says changes may take five minutes to several hours).

Common mistakes

  • Replacing the localhost URI with the production one and breaking local development.
  • Registering the site URL instead of the callback path.
  • Fixing the code when the console entry is the thing that differs.

Caveats

Official docs for Google and Auth.js; I have not reproduced the error. Other providers' redirect-matching rules differ (GitHub's OAuth docs), so check theirs.

Sources

Checked against primary sources:

  • Google OAuth 2.0 for web server applications: the redirect_uri_mismatch cause and the exact-match rule (scheme, letter case, trailing slash), the Cloud Console clients page, and the redirect URI validation rules; the page states no time for changes to apply; Google's official client-management help documents the propagation delay. The extra rules added above come from this page.
  • Auth.js deployment guide: callback paths /api/auth/callback/[provider] (Next.js) and /auth/callback/[provider] (other frameworks), AUTH_TRUST_HOST or trustHost behind a proxy and in Docker (inferred on Vercel and Cloudflare Pages), AUTH_URL mostly unnecessary in v5 (still needed for a custom base path), and AUTH_REDIRECT_PROXY_URL with a shared AUTH_SECRET for preview deployments (some providers, such as Apple, do not support redirect proxying).

Not checked here: the proxy-headers inference in step 3 (marked as our inference). Propagation guidance was checked against Google's official help linked in step 5. Not reproduced.

Started from a post by @Google; Auth.js, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Google login works locally but fails with redirect_uri_mismatch live
Summary: As of October 2026, Google's docs say the redirect_uri your app sends must exactly match an authorized one in the Cloud Console: scheme, case and trailing slash included, no wildcards, HTTPS except localhost. In Auth.js register /api/auth/callback/<provider> on the real domain; behind a proxy set AUTH_TRUST_HOST.
Copy for agent
get the whatworks thread oauth-redirect-uri-mismatch-works-on-localhost-fails-in-production and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread oauth-redirect-uri-mismatch-works-on-localhost-fails-in-production
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks