Lovable password reset link not working or sending users to the wrong page

Updated · by Zane

How a password reset is supposed to work

There are three parts. Your app asks for a reset email. The person clicks the link in it. The link brings them back to a page of yours, where they choose a new password.

Supabase, which handles login for Lovable apps, describes the same three parts. The request can carry a redirectTo address that should point to a change password page. That address must be on the Redirect URLs list. When it is not given, Supabase uses the Site URL. The page then collects the new password and calls updateUser.

So a link that goes to the wrong place is almost always a settings problem. A link that goes to the right place and shows nothing useful is a page problem.

A reset has three parts: the request carries a redirectTo address, the email link brings the person back to a page of yours, and that page saves the new password. It can break at the numbered points: 1, the link points to the wrong address; 2, the page is missing or blank; 3, the link has already been used.

Step 1: look at where the link actually goes

  1. Open your real site in a private window and request a password reset for a test account.
  2. Open the email and copy the link from the button instead of clicking it.
  3. Find the part that says redirect_to=. That is where the person will land.
  • It shows localhost, a preview address, or your home page: go to step 2.
  • It shows the right page but the page is missing or blank: go to step 3.
  • You land on the right page but it says the link is invalid or expired: go to step 4.

Step 2: fix Site URL and Redirect URLs

Lovable's authentication guide says the two settings are under More, then Cloud, then Users, then Auth settings, in the Advanced section. It also says that with the built-in backend Lovable keeps them up to date, unless you set the Site URL yourself. Apps with their own Supabase project get no automatic updates.

  1. Set Site URL to your real domain, starting with https.
  2. Add the exact reset page to Redirect URLs, for example https://yourdomain.com/reset-password. A wildcard such as https://yourdomain.com/** also works.
  3. If your app uses its own Supabase project, make the same change in the Supabase Dashboard under Authentication, then URL Configuration.
  4. Save, then request a new email. Old emails keep their old address.

This is the same cause as login sending people to localhost, and the screens are the same. The longer walkthrough is in login redirects to localhost after publishing.

Step 3: make sure the reset page exists and works

The address in the email is only a destination. If your app has no page at that path, the visitor sees the home page, a 404 or a blank screen. Ask Lovable's chat: "Does my app have a page at /reset-password that lets users set a new password? Show me the code."

If it does not, ask Lovable to add one. A working version has two parts. The request tells Supabase where to send the link:

Requesting the email
// Ask for the reset email, and say where the link should land
const { error } = await supabase.auth.resetPasswordForEmail(email, {
  redirectTo: `${window.location.origin}/reset-password`,
});

And the page listens for the recovery event, then saves the new password. Supabase's reference shows this pattern with onAuthStateChange and updateUser:

The /reset-password page (sketch)
// The /reset-password page. It must be reachable without being logged in.
const [ready, setReady] = useState(false);

useEffect(() => {
  const { data } = supabase.auth.onAuthStateChange((event) => {
    if (event === "PASSWORD_RECOVERY") setReady(true); // show the new-password form
  });
  return () => data.subscription.unsubscribe();
}, []);

async function save(newPassword: string) {
  const { error } = await supabase.auth.updateUser({ password: newPassword });
  if (error) console.error(error.message);
}

Two things commonly break this page. The first is a route guard that sends anyone who is not fully logged in to the login page. The recovery link signs the person in only for a moment, so a guard that checks too early sends them away. Keep this page outside the guard, and wait for the session to load before deciding anything. The second is code that sends people to the home page right after the link opens. If you see the address bar change to your home page within a second, look for a redirect like that.

Treat the code above as the pattern to ask for, not as your project's exact code. I could not confirm what Lovable generates by default for this page, so read what is actually in your project.

Step 4: the link says it is expired or invalid

Reset links are single-use. Supabase's email documentation says some email providers scan links before the person opens the message, and that this can use the link up and produce a "Token has expired or is invalid" error. Microsoft Defender for Office 365 Safe Links is its example.

  • Request a new link and open it straight away from the inbox.
  • If many users hit this, Supabase suggests changing the email template so the link opens a page of yours first, where the person clicks a button to continue. A code the person types in is the other option.
  • On Lovable, email templates are under More, then Cloud, then Emails. Lovable warns that the required variables and callback links must stay in the template or login flows will break.

Test the fix

  1. Open your real domain in a private window and click Forgot password.
  2. Request a new email for a test account and click the link in it.
  3. Check that you land on the reset page and the new-password form appears.
  4. Save a new password, then log in with it.
  5. Check that the old link now fails. Single-use links should.

Related

Once login works, check what users can read afterwards. Is your Supabase data public? takes about two minutes.

FAQ

The link says it has expired, but I just requested it. Why?

Some email systems open links to scan them before the person does. Supabase's email documentation says the link is then used up, which can show a "Token has expired or is invalid" error. Request a new email and click the link straight from the inbox. If it keeps happening, the lasting fix is a template that links to a page with a button.

Do I have to add the reset page to the redirect list?

Yes, if your code passes redirectTo. Supabase says the address should match the Redirect URLs list, and that Site URL is the default when no address is given. Add the exact page, for example https://yourdomain.com/reset-password.

Where do I change these settings in Lovable?

Lovable's authentication guide says to open More, then Cloud, then Users, then Auth settings, and look under Advanced for Site URL and Redirect URLs. With the built-in backend, Lovable keeps both up to date unless you set the Site URL yourself. With your own Supabase project, it does not, so change them in that project's auth settings.

Old reset emails still point to the wrong place after I fixed the settings.

Links in emails that were already sent were built with the old settings and will not change. Request a new reset email every time you retest.

Checklist

Still stuck?

Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.

Related guides