For builders shipping this week
Supabase password reset or magic link opens localhost after deploy
You deployed a Lovable, Bolt, or Cursor app. Sign-up works in the preview. A real person requests a password reset or a magic link, clicks it, and the browser opens http://localhost:3000.
Test your app's sign-up for free
The address in that email comes from the Supabase project the app uses. Supabase's redirect URL guide says the Site URL is the default destination when the code does not pass its own redirect, and that new projects start at http://localhost:3000. Change it to the published URL. The same page says this setting matters for email confirmations and password resets.
This is a different failure from Email link is invalid or has expired, where the token was used or expired. A shorter German note on confirmation links that open localhost is Der Bestätigungslink, der auf localhost zeigt. If the link already opens your live domain and the person is still logged out, see email link opens the site but the user isn't logged in.
1. Set the Site URL to the address visitors use
Open the Supabase project → Authentication → URL Configuration. Set Site URL to the published address, including https, for example https://yourapp.com. If the app is also served on www, pick the host people actually open. The other host is a different URL.
If the code omits a redirect, Auth uses this Site URL. That default is why a Site URL of http://localhost:3000 still opens localhost after you deploy. A redirectTo you do pass has to match the Redirect URLs list. If it does not, do not assume the email will use it: the request can fail, and that failure is returned on error rather than thrown (step 6), or the link can be sent to the Site URL instead.
2. Allow the exact reset or confirm URL
The password guide says the redirect you pass has to be configured under Redirect URLs. The allow list compares the full URL. https://yourapp.com/account/update-password does not match the http version, the www host, or a different path.
Wildcards are documented on the redirect URL page. * matches a sequence of characters that does not cross / or .. ** matches any sequence, including those separators. Their example http://localhost:3000/* matches /foo and /bar, and does not match /foo/bar or /foo/ (the trailing slash). ** does match /foo/bar.
Supabase recommends the exact redirect path in production. Keep ** for local development and preview URLs, such as a Vercel preview. For the live app, add the real URL, for example https://yourapp.com/account/update-password or https://yourapp.com/auth/confirm. Add the www copy only if you send people there too.
3. Stop the code from asking for localhost
resetPasswordForEmail takes redirectTo. signUp and signInWithOtp take emailRedirectTo for the confirmation or magic link. Search the project for both names.
A string http://localhost:3000 sends every email there. window.location.origin is the origin of the page that requested the email. On the Lovable or Bolt preview, or on your own localhost, that origin is not the published site, so the email is built for the preview. The redirect URL guide shows a production site URL (their example reads NEXT_PUBLIC_SITE_URL) and only falls back to localhost in development. The published origin still has to be on the Redirect URLs list, character for character.
4. Point the email template at RedirectTo
The same guide says that when you pass redirectTo, the template should use {{ .RedirectTo }} instead of {{ .SiteURL }}. A template that still prints Site URL keeps sending people to whatever Site URL is, even after the code passes the right path. In Authentication → Emails, check the reset, magic-link, and confirm templates.
5. Check supabase/config.toml before the next push
The CLI config reference lists auth.site_url with the default "http://localhost:3000". That file configures the local stack. The command supabase config push uploads config.toml to the linked project. If site_url in the file is still localhost, the push replaces the Site URL you set in the dashboard. A branch deploy that applies the same file can do the same.
Open supabase/config.toml if the repo has one. For a project you push, set site_url from the environment (the CLI accepts env(SITE_URL)) or from a [remotes] block, so production is not the local default. After any push, reopen URL Configuration and read Site URL again.
6. Request a new email, and read the returned error
The redirect is written into the message when it is sent. An email already in the inbox still opens the old address after you fix the dashboard. Request a new reset or magic link, and click that one.
resetPasswordForEmail resolves with { data, error }. The JavaScript reference shows that shape, and supabase-js returns an error object for an unsuccessful request instead of throwing. A try/catch that never reads error looks like success. Check error before you tell the user the email was sent. A redirect URL that is not allowed can show up there.
The password docs also say the method does not reveal whether an account exists. When no user has that address, Auth sends no email and still returns without an error. A missing error does not prove the message went out.
Checklist
- Site URL is the published https address, not http://localhost:3000.
- The exact reset or confirm URL is on Redirect URLs, including scheme, host, and path.
- Production uses that exact path. The ** wildcard is for preview URLs.
- redirectTo and emailRedirectTo are not localhost, and not the preview origin.
- The email template uses {{ .RedirectTo }} when the code passes a redirect.
- supabase/config.toml is not pushing site_url = http://localhost:3000 back over the dashboard.
- You requested a new email after the change. The old one still has the old link.
- The reset call checks the returned error. It does not throw.
Test it from the published URL
- Open the published URL in a private window. Do not use the editor preview or localhost.
- For a reset, use an address that already has an account. For a confirmation or magic link, use an address that has never signed up.
- Request a new email after the settings change. In the message, the link's
redirect_toshould be your published URL, not localhost. - Click it once. You should land on the published path and be able to set a password or finish sign-in.
- If it still opens localhost, check Site URL, the exact Redirect URLs entry, the template, and whether you clicked an older email.
FirstUser's free sign-up test opens the published URL as a new visitor and signs up. When it can see the confirmation email, it follows that link. It is a sign-up test, so it does not request a password reset for you. Use it to see whether a brand-new visitor gets through sign-up on the live URL.
FAQ
I changed the Site URL. Why does the email still open localhost?
The link already in the inbox was built when that email was sent. Request a new reset or magic link and use that one. Then reopen Authentication, URL Configuration, in case a config push wrote localhost back.
I added https://myapp.com/** and the link still misses the page.
A double asterisk matches across slashes, and Supabase recommends the exact production path instead. Also compare https with http, www with the bare host, and a trailing slash. A single asterisk does not match a path that contains another slash.
The reset button does nothing, and the console shows no exception.
resetPasswordForEmail resolves with an error object and does not throw for an Auth failure, so check error before telling the user the email went out. An address with no account also returns no error and sends no email.
Do magic links and signup confirmation use the same settings?
Yes. They use the same Site URL and Redirect URLs. signUp and signInWithOtp pass the address as emailRedirectTo. resetPasswordForEmail passes redirectTo.
Can a free sign-up test catch a localhost confirmation link?
The free sign-up test opens the published URL and signs up as a new visitor. It follows the confirmation email when it can see the message. It does not request a password reset.