Password reset link opens localhost, or says it is invalid or expired
A Supabase password reset on an app built with Lovable, Bolt, Replit, Cursor or v0 opens localhost, or the link is already invalid. How to check the Site URL, redirect allow list, redirectTo, scanners, and the reset page.
You shipped an app with Lovable, Bolt, Replit, Cursor or v0, connected Supabase Auth, and password reset works on your machine. On the live site the link opens localhost, or the right site says the link is invalid or has expired. The form then fails, because it never got a session it can use to save a new password.
Supabase picks the destination from the Site URL, the redirect allow list, and the redirectTo your code passes. Whether the link still works depends on a one-time token, an expiry setting, and whether a scanner, an earlier click, or another browser already consumed that token. Other auth providers fail the same way when a public URL is still localhost, a redirect is not allow-listed, or a one-time email link is spent before the person uses it.
Site URL is still localhost
Open Authentication, then URL Configuration. Site URL is the address used when your code does not pass a redirect. It defaults to http://localhost:3000. Supabase's docs say to change it to your production URL.
Set it to the live origin, such as https://yourapp.com, including https and without a port, path, or preview host unless the app really lives there. Save, then request a new reset.
The redirect allow list is missing the live page
On that same page, Redirect URLs is an allow list. redirectTo is only used when that exact URL is listed. Supabase's note on links that still open localhost is this: if the URL is not in the list, it is not used, and people land on the Site URL instead.
Add the reset page, for example https://yourapp.com/update-password. A single-segment wildcard does not cross . or /, so a pattern ending in one star matches /update-password and misses /account/update-password or a trailing slash. A double star crosses segments. Supabase recommends an exact production path and wildcards for previews. These are the patterns from their redirect docs:
https://yourapp.com/*
https://yourapp.com/**
https://*-.vercel.app/**
https://**--your-org.netlify.app/**
http://localhost:3000/**
A Lovable, Bolt, or other builder preview host needs its own entry if you test reset from that URL.
redirectTo is missing, or it points at the wrong origin
Search the project for resetPasswordForEmail and pass the page on the site the person is using:
await supabase.auth.resetPasswordForEmail(email, {
redirectTo: `${window.location.origin}/update-password`,
})
Generated code usually misses this in one of three ways. There is no redirectTo, so Supabase uses the Site URL. The value is hardcoded to http://localhost:3000/.... Or it uses window.location.origin while you are on a preview, so the email targets a host that was never allow-listed.
On the server, build the URL from the public site origin in the environment. If that variable is still localhost in production, every reset email will be too.
A mail scanner already opened the link
The default Reset password template uses {{ .ConfirmationURL }}, a link to your project's /auth/v1/verify endpoint. The token works once. Mail security tools, including Microsoft Safe Links and similar corporate scanners, fetch links before the person clicks and spend it. The person sees "Email link is invalid or has expired", and the Auth logs show otp_expired seconds after the send, from an IP that is not theirs.
Avoid a URL that verifies itself. Put {{ .Token }} in the template (six digits by default) and have the person type the code. Or link to a page you own with {{ .TokenHash }} and type=recovery, and call verifyOtp({ type: 'recovery', token_hash }) only when they press a button. If the server verifies on the first request, the scanner still spends the token. A failure logged before anyone could have clicked is a scanner, not a bad Site URL.
The token was already used, or it was opened in another browser
A recovery token is single-use, so a second click fails. Requesting another reset replaces the previous token, and the older email then fails as expired too. Say that on the error page, and offer to send a new one.
Client-only JavaScript uses the implicit flow by default. The redirect returns the session in the URL hash with type=recovery, and that link works in any browser. onAuthStateChange emits PASSWORD_RECOVERY and SIGNED_IN. Wait for PASSWORD_RECOVERY, then call updateUser({ password }).
Server-rendered apps using @supabase/ssr use the PKCE flow. Supabase stores a code verifier in the browser where the reset was requested, and the exchange has to run in that same browser and on that same device. The link comes back with a code parameter. Opening it elsewhere, including a mail app's built-in browser, fails with bad_code_verifier, flow_state_not_found, or flow_state_expired. Ask the person to request the reset and open the email in the same browser.
The reset page never establishes a session
updateUser needs a session. A generated page that only renders a form never creates one.
On the implicit flow the tokens are in the URL hash, which the server never sees. The browser client reads them when detectSessionInUrl is on (the default). Wait for PASSWORD_RECOVERY, then show the form.
On the PKCE flow a route, often /auth/confirm or /auth/callback, has to call exchangeCodeForSession(code) or verifyOtp with type: 'recovery' and the token_hash before the form runs. If that route is missing, the address bar still shows code or token_hash and updateUser returns a session error. Listening only for PASSWORD_RECOVERY on a PKCE app that never exchanges the code leaves the same broken form. After a successful update, log out and log in with the new password.
The link is actually expired
Recovery links share a lifetime with other email links and codes. The setting is Authentication, then Sign In / Providers, then Email, then Email OTP Expiration. The default is 3600 seconds, one hour. A link older than that fails even if nobody else opened it. Supabase discourages a value above one day. Keep the lifetime modest, and tell people on the expired page how to request a fresh email.
The template uses the wrong URL variable
If you edited the Reset password template, check the link.
{{ .ConfirmationURL }}is the full verify link, including the redirect. The default template uses it.{{ .SiteURL }}is only the Site URL. It has no token, so a button pointing here resets nothing.{{ .RedirectTo }}is theredirectToyour code passed, with no token of its own.{{ .TokenHash }}is for a link you build, paired withtype=recovery.{{ .Token }}is the code the person types.
A hardcoded http://localhost:3000, or swapping {{ .ConfirmationURL }} for {{ .SiteURL }}, opens localhost or opens the right site with nothing to exchange. When you build the link yourself and you pass redirectTo, put {{ .RedirectTo }} in it. Send a new email after every template edit.
Test it with a real inbox
Run this on the live domain after each change. Old emails keep the previous link.
- Request a reset to an inbox you control. Copy the link before opening it.
- It should go to your project's
supabase.coverify URL, andredirect_toshould be your live reset page. Site URL should be that origin, and the page should match a Redirect URLs entry. - Open the link once, in the same browser you used to request it. Set a new password, log out, and log in with it.
- Request a second email and click the first link. It should fail, and the page should say the link was already used and offer another reset.
- If step 3 fails immediately, check the Auth logs.
otp_expiredorflow_state_not_foundfrom before you clicked means a scanner. Aredirect_toof localhost means the Site URL, the allow list, orredirectTo.
If your users are on corporate mail, repeat step 3 with that kind of inbox. A personal Gmail test will not show a Safe Links prefetch.
A later edit can put localhost back into redirectTo or drop {{ .ConfirmationURL }} from the template, while the homepage still returns 200. Confirm the reset page itself loads with the free check: it opens one page in a real browser and reports the HTTP status, console errors, broken links, unfinished buttons and load time, with a screenshot. It does not send the reset email or follow the link, so the inbox steps above are still what prove the flow.