# Magic link / OAuth login redirects to localhost:3000

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-auth-redirect-localhost.html
> Category: Auth | Tools: Lovable, Bolt, v0, Cursor | Published: 2026-10-13 | Updated: 2026-10-13

## The error

After clicking the email link or Google login, the browser opens http://localhost:3000

## Why it happens

Supabase Auth's Site URL is still set to localhost, or your production URL isn't in the Redirect URLs allow-list, so Supabase falls back to the Site URL.

## How to fix it

1. Supabase → Authentication → URL Configuration: set Site URL to your production URL.
2. Add production and preview URLs to Redirect URLs (wildcards like https://*-yourteam.vercel.app/** are allowed).
3. Pass emailRedirectTo / redirectTo using window.location.origin.
4. For Google OAuth, the Google Cloud console redirect URI must be your Supabase callback URL (https://<ref>.supabase.co/auth/v1/callback).

## Error codes this fixes

- `Redirect to http://localhost:3000 after login` (Supabase Auth): https://unbreakmyapp.vercel.app/errors.html#redirect-to-http-localhost-3000-after-login

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Supabase login redirects users to localhost after deploy. Update the auth calls to pass redirectTo/emailRedirectTo built from window.location.origin plus our callback path, add an /auth/callback route that exchanges the code for a session, and tell me exactly which Site URL and Redirect URLs to set in the Supabase dashboard for <PRODUCTION_URL>.
```

## FAQ

### Do I need to change Google Cloud settings?

Only the authorised redirect URI, which should be the Supabase callback URL, not your site.

### Why localhost?

It's Supabase's default Site URL from when the project was created.

## Sources (official documentation)

- [Supabase: Redirect URLs](https://supabase.com/docs/guides/auth/redirect-urls)

## Related fixes

- [Supabase project paused: app suddenly can't connect (Failed to fetch, 540) and how to bring it back](https://unbreakmyapp.vercel.app/fixes/supabase-project-paused-app-cant-connect.html)
- [App works on localhost but breaks in production: a checklist to find the cause](https://unbreakmyapp.vercel.app/fixes/works-on-localhost-breaks-in-production.html)
- [Error 400: redirect_uri_mismatch (Google sign-in)](https://unbreakmyapp.vercel.app/fixes/oauth-redirect-uri-mismatch.html)
- [User is logged out after page refresh](https://unbreakmyapp.vercel.app/fixes/session-lost-on-refresh.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
