On this page
Google login after a domain change
Why does Google login work in preview but fail on my custom domain?
Three different addresses are involved. The provider callback is where Google sends the sign-in result: your auth service's callback, such as Supabase's /auth/v1/callback, or a route in your own app when the app is the OAuth client, as with Auth.js. It must exactly match an authorized redirect URI on the Google client, or Google shows redirect_uri_mismatch. The app return URL is where the auth service sends the user next, and it must be on that service's allow list. The Site URL is the fallback when no return URL is sent. Find the hop that failed and change only that setting.
npx -y viberaven@1.8.0 checkIt lists launch gaps in a Vercel + Supabase repo, such as tables without row level security in the migrations and a service role key in client code. It runs locally with no account and reads the repo, not your live database: advice, not a gate.
Or ask your coding agent to "run npx -y viberaven@1.8.0 check and fix what it reports".
Why this matters
A working preview does not prove the custom-domain sign-in works. Changing the wrong URL can leave the original fault in place. With Supabase in the middle, a new app domain changes the app return URL and the Site URL, while the Google redirect URI stays the Supabase callback. When the app itself is the OAuth client, the Google redirect URI is on the app domain and changes with it. First identify your setup: managed Lovable Cloud authentication, your own Google credentials in Lovable Cloud, an external Supabase project, or an auth library such as Auth.js.
Diagnose the failing hop before changing settings
- 1Start sign-in from the failing custom domain. Record the visible error and the address where the flow stops. A login screen, successful deployment or HTTP 200 alone does not prove a user session exists.
- 2Name the hop from what you see. An error page from Google that names redirect_uri_mismatch means the provider callback. Google accepts the login but you land on the Site URL, such as the homepage or localhost:3000, instead of the page you asked for: the app return URL is missing from the allow list or was never sent; Bolt's docs for its Supabase-based auth describe that fallback. You land on the right page but signed out, or on an auth error route: inspect the callback error, code exchange and session cookies. A failed exchange or later session handling can cause this; the symptom alone does not identify which failed.
- 3For redirect_uri_mismatch, inspect the authorization request in the browser network panel and compare only its redirect_uri with the registered Google callback. Google requires an exact match, including scheme, case and trailing slash, HTTPS except on localhost, and no wildcards or fragments, so a pattern cannot cover changing preview URLs. Do not share the full request URL, authorization code, tokens or state.
- 4Use the matching setup below. Keep the Google callback, the application return URL and the default Site URL separate. Do not replace every address with your homepage.
- 5If your deployed code builds a redirect from an environment variable, verify the value for the deployment you are testing and redeploy after correcting build-time configuration. On Vercel, VERCEL_URL is the generated deployment address on vercel.app, not your custom domain, so a production return URL built from it sends users to the wrong host.
- 6After the change, use a fresh private browser session on the custom domain. Sign in, reload a protected page, perform one permitted account action, then sign out. Repeat on a preview if previews must remain supported.
Which settings belong to your stack?
Lovable Cloud with managed Google authentication
Lovable documents automatic auth URL updates when publishing or connecting a custom domain. A manually overridden Site URL remains unchanged. Check for that override before assuming a missing Google Console entry.
See the fix
Managed Google authentication does not require your own Google OAuth client setup. Make sure you are debugging sign-in for users of your published app, not sign-in to your Lovable workspace.
Lovable Cloud with your own Google credentials
Open More → Cloud → Users → Auth settings → Google. Copy the exact redirect URL shown there into the authorized redirect URIs for your Google client, then select that redirect in Lovable and save. Do not invent a callback path from the custom domain.
An external Supabase project
Lovable does not automatically update an external Supabase project’s auth settings. For Google login, copy the callback from Supabase’s Google provider configuration into Google’s authorized redirect URIs. Google’s authorized JavaScript origins contain app origins; they are a separate field.
See the fix
In Supabase Auth URL Configuration, Site URL is the fallback when no redirectTo is supplied. Set the intended production default. The app’s redirectTo must match an allowed Redirect URL. Use exact production paths; apply preview patterns only to the preview addresses you need.
If using Vercel previews, Supabase’s redirect guide shows a preview pattern and a production/preview URL helper. Follow those for app return URLs. Do not paste a Supabase wildcard into Google’s exact callback list.
The helper in that guide reads NEXT_PUBLIC_SITE_URL before NEXT_PUBLIC_VERCEL_URL. Set NEXT_PUBLIC_SITE_URL to the custom domain in the Production environment; without it, production builds the return URL from the vercel.app deployment address.
With server-side auth, the app return URL is a route in your app, such as /auth/callback, that exchanges the code for a session. Supabase stores the code verifier in a cookie when sign-in starts; if that cookie does not reach the browser, the exchange fails and the user arrives signed out even though both redirects worked.
Your app is the OAuth client, as with Auth.js
Here there is no auth service between Google and the app, so the provider callback is on your app domain. Auth.js documents https://your-domain/api/auth/callback/google for Next.js apps and /auth/callback/google for its other framework packages. Add the exact callback for each domain users sign in on, including the custom domain, to the Google client's authorized redirect URIs.
See the fix
Auth.js v5 infers the host from request headers, and its docs say AUTH_URL is mostly needed only for a different base path. For preview deployments, Auth.js describes a stable deployment as a redirect proxy: set AUTH_REDIRECT_PROXY_URL to it in the stable and preview environments, use the same AUTH_SECRET in both, and register only the stable callback with Google.
A URL map to use while diagnosing
This is an illustrative configuration map, not a tested deployment. Copy actual values from your provider settings; the example addresses are placeholders.
External Supabase plus Google
| Setting | Illustrative value or source | Purpose |
|---|---|---|
| Google authorized redirect URI | Exact callback copied from Supabase’s Google provider panel | Google returns the response to the auth service |
| Supabase Redirect URLs and app redirectTo | https://app.example.com/auth/callback, if that route exists in your app | The auth service returns the user to the app |
| Supabase Site URL | https://app.example.com | Fallback return address when redirectTo is absent |
| Google authorized JavaScript origins | https://app.example.com | The app origin, a separate field from the redirect URIs |
The three hops in order
Each line names the address in play and the setting that has to allow it. The error you see points at the hop that stopped.
1. The app starts sign-in with redirectTo https://app.example.com/auth/callback
2. Google returns the result to https://<project-ref>.supabase.co/auth/v1/callback
allowed by: Google authorized redirect URIs (exact match, else redirect_uri_mismatch)
3. Supabase sends the user to https://app.example.com/auth/callback?code=...
allowed by: Supabase Redirect URLs (not listed or not sent: the Site URL instead)
4. The /auth/callback route exchanges the code for a session cookie
fails when: the code verifier cookie is missing, so the user lands signed outApp as the OAuth client: Auth.js on Next.js
| Setting | Illustrative value or source | Purpose |
|---|---|---|
| Google authorized redirect URI | https://app.example.com/api/auth/callback/google | Google returns the response to the app itself |
| AUTH_REDIRECT_PROXY_URL, stable and preview environments | https://auth.example.com/api/auth, a deployment whose URL does not change | Lets previews sign in through one registered callback |
| AUTH_SECRET | The same value on the stable and preview deployments | Lets the stable deployment hand the session back to the preview |
Related guides
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ for builders before launch
Should I change my RLS policies to fix redirect_uri_mismatch?
No. Fix the callback mismatch first. Database permissions do not register a Google OAuth redirect URI. If login succeeds but loading data fails, investigate that as a separate authorization problem.
Does fixing the callback prove the app is ready to launch?
No. It proves only the retested sign-in flow works in that environment. Test session persistence and the account action you need, then continue the broader launch checks.
What if I use Auth.js, Clerk or another provider?
For Auth.js, use the app-as-client case above: the Google callback is on your own domain. For Clerk or another provider, find the callback URL generated by that integration and follow its provider-specific documentation. The Supabase callback map on this page does not apply to every auth library.
Do I need to change Google settings when I add a custom domain to a Supabase app?
Usually not the redirect URI. With Supabase as the auth service, Google returns to the Supabase callback, which does not change with your app domain. Update the Supabase Site URL and Redirect URLs, and add the new origin to Google's authorized JavaScript origins, which Supabase's Google guide asks you to set to your app URL.