A supabase reset password email arrives. The user clicks it and lands on localhost, the home page, a login screen, an expired-link error, or Auth session missing! when saving the new password.
Your preview test can pass on one laptop while a real customer fails on a phone, behind a corporate mail scanner, or on the production domain.
What is actually failing
Password recovery is a chain, not one step: the form calls resetPasswordForEmail(email, { redirectTo }), Supabase sends a one-time link, the link returns to an allowed URL, the app creates a recovery session from the token or code, and only then can updateUser({ password }) save the new password.
Every layer can produce the same complaint: “password reset is broken”. The repair is different each time, so assign the failure to a layer before rewriting auth.
Why AI-built apps miss it
The AI usually proves the happy path in one browser. Production adds what the demo omitted: a disallowed deployed domain, another device, a scanner that opens the URL first, or a router guard that removes the recovery code.
resetPasswordForEmail also hides whether the address exists. An unknown address can return without an error while no email is sent — user-enumeration protection, not proof of a mail bug.
supabase reset password production click path
- Name the exact symptom and test a known account. “No email”, “wrong page”, “expired link”, “missing session”, and “password does not save” are different failures. Use an address you control and know is registered.
- Separate delivery from reset logic. If nothing arrives, first follow the supabase smtp production path: sender quota, custom SMTP, suppressions, spam, and rate limits.
- Copy the link target before clicking. Check whether it points to Supabase verify, your own confirm endpoint, a tracking wrapper, or your domain.
- Make the destination explicit and allowed. Pass
redirectToas the production URL of a public update-password or auth-confirm page. Set Site URL to the production origin, not localhost, and add that exact recovery path to the Redirect URLs allow list. - Inspect the email template. A hard-coded
{{ .SiteURL }}can ignore the intended redirect. Server-side and PKCE flows need the documented token-hash pattern withtype=recoveryand a safenexttarget. - Watch the browser redirect and router guards. Preserve the network log. Confirm that the user reaches the intended page with
?code=or a fragment token; a guard that redirects “not logged in” visitors can strip it before Supabase exchanges it. - Confirm the recovery event. Log — without printing tokens — whether
onAuthStateChangeemitsPASSWORD_RECOVERY. Without that session,updateUsercannot work. - Test cross-device PKCE behavior. PKCE stores its code verifier where the flow starts. A reset requested on desktop can fail when the email is opened in a mobile mail app.
- Check scanner consumption. Rapid
otp_expiredor 403 entries on the verify endpoint shortly after sending point to prefetching or a safe-link scanner consuming the one-time token. - Test updateUser last. Submit one new password in production and read the exact error.
Auth session missing!means the local recovery session never existed; it does not mean the password field is wrong.
The redirect mistake that sends users home
If the redirect URL is not allowed, Supabase can fall back to the referrer or Site URL. That is why users land on localhost, the home page, or a 404 even though the application code looks correct.
Browsers often send only the origin as referrer, not the full forgot-password path. A template that hard-codes the Site URL can also bypass the carefully passed redirectTo. Production needs one explicit recovery destination, identical in code, template, and allow list.
Implicit flow versus PKCE flow
Plain browser clients often use the implicit flow: tokens return in the URL fragment and the browser client creates a session. Server-side rendering commonly uses PKCE: the URL contains a one-time code that must be exchanged first.
PKCE is appropriate for server-side auth, but the code is short-lived, single-use, and tied to the stored verifier. Test the same-browser path and the realistic cross-device path separately instead of treating either failure as a random Supabase outage.
“Expired” can mean “already opened”
Security software can open the link before the human. It scans incoming mail, consumes the one-time token, and leaves the real user with an invalid or expired message. Link tracking can also rewrite the original URL and lose nested parameters.
Compare send time, verify-endpoint response, auth log error, and user click time. If the token was consumed seconds after delivery, a longer expiry is not the fix. Disable click tracking for auth mail where possible, use a manually entered recovery code, or require a deliberate user action before consuming the token.
The missing page problem
Sometimes the recovery session works, but the user has nowhere to set a password. The app sends them to the dashboard, login, or a protected account page. The session exists; the interface is missing.
The update page must accept the recovery redirect, collect the new password, call updateUser, show the exact error, and only then redirect onward. A generic auth page is not enough when the broader flow is already fragile, as the supabase auth production guide shows.
Production checklist
- The test address belongs to an existing user, and mail delivery was checked separately through SMTP.
- Site URL is the production origin, and the exact recovery URL is in the Redirect URLs allow list.
redirectTois explicit and matches that allowed URL.- The email template preserves the redirect and does not break nested parameters.
- Click tracking does not rewrite or consume the recovery link.
- The network log shows the code or token reaching the intended page without an auth guard stripping it.
PASSWORD_RECOVERYappears before the new-password form submits.- Cross-device PKCE behavior was tested, not only same-browser preview behavior.
updateUserruns only after a recovery session exists.- Scanner-driven
otp_expiredis distinguished from real expiry, and the wider launch path still passes the lovable deploy checklist.
Once the failure is assigned to sending, redirect, template, token exchange, scanner behavior, or the missing recovery session, the fix becomes small. If sign-in loops, wrong providers, or confirmation-mail failures remain, continue with the wider lovable authentication errors triage.
FAQ
Why does supabase reset password work in preview but fail in production?
Preview often uses localhost and the same browser. Production adds real redirect URLs, scanners, devices and a separate runtime. Check the allow list, email link target, PKCE exchange and PASSWORD_RECOVERY session before updateUser.
Why do I get Auth session missing after clicking the reset link?
updateUser requires a recovery session. It is missing when a guard strips the token or code, the PKCE exchange never ran, the code was consumed, or the link opened in a different browser.
Why does the reset email expire immediately?
Email prefetching or a security scanner often opens the one-time link first. Logs then show otp_expired or a 403 on verify seconds after sending. Disable link rewriting where possible or use a manually entered recovery code.