Short answer
Most Supabase Auth problems are settings, not code. Keep e-mail confirmation on, set the Site URL to your production domain, allow only exact redirect URLs, send password reset links to a dedicated page that calls updateUser, show the same message whether or not an account exists, and remember that anonymous users have the authenticated role, so protect writes with a restrictive policy on the is_anonymous claim.
Ask an AI about this page:ChatGPTClaude
On this page
Key takeaways
- Keep Confirm email on. Turning it off marks every address as confirmed, so an e-mail no longer proves anything.
- Change the Site URL from
http://localhost:3000to your production URL before launch. - The Redirect URLs allow list decides where login and reset links may send tokens. Use exact URLs in production;
**matches anything. - Reset links should land on a change-password page that calls
updateUser, not on your home page. - Anonymous users have the
authenticatedrole. Block them from writes with a restrictive policy onis_anonymous.
Why Auth settings matter as much as code
Supabase Auth handles passwords, e-mails and tokens for you, which removes a lot of risk. What it can’t decide for you is how your project is configured: where links may point, whether an address must be proven, who counts as “signed in”. Those settings live in the dashboard under Authentication, not in your repository, so an AI builder that writes your sign-up form usually never sees them. Here are the six we would check first.
1. E-mail confirmation switched off
The e-mail provider in your Auth settings has a Confirm email switch. Supabase’s docs say it is on by default for hosted projects and off for local development and self-hosting. When it is off, users can sign in without clicking a link, and Supabase notes that disabling it implicitly confirms the user’s e-mail in the database.
That is fine for a prototype. It becomes a problem when anything trusts the address:
- an invite or team feature that grants access because the e-mail matches,
- a policy that checks the e-mail domain, such as “everyone at
@yourcompany.exampleis staff”, - support staff who treat “the e-mail on the account” as proof of identity.
With confirmation off, anyone can register ceo@yourcompany.example and pass all three. Keep it on, and if you turn it off for testing, turn it back on before launch.
To see who signed up but never confirmed (bots and typos are common), run this in the SQL Editor:
select id, email, created_at
from auth.users
where email_confirmed_at is null
order by created_at desc;2. The Site URL still points at localhost
The Site URL in Authentication → URL Configuration is the default redirect when your code passes no redirectTo. It starts as http://localhost:3000. If you never change it, confirmation and magic links in production send users to a page that doesn’t exist on their machine, and people start “fixing” it by adding broad wildcards to the redirect list. Set it to your production URL, for example https://your-app.example.
3. A redirect allow list that allows too much
Login links, magic links, OAuth and password reset all end with a redirect back to your app, and that redirect carries what the user needs to sign in. The Redirect URLs list decides which targets are allowed: the URL you pass as redirectTo has to match it.
Supabase supports wildcards: * matches any characters except the separators . and /, and ** matches anything. That is convenient and easy to overdo:
| Entry | What it allows |
|---|---|
https://your-app.example/auth/callback | exactly one page: what you want in production |
https://*-your-team.vercel.app/** | your team’s Vercel previews (Supabase’s suggested pattern) |
https://*.vercel.app/** | every Vercel deployment, including other people’s |
https://** or ** | anywhere at all |
Supabase recommends setting the exact path in production. The risk of a broad entry is that a link to your real login can be crafted to send the user, and their sign-in, to a site someone else controls. Our fixes for a password reset that redirects anywhere and an open redirect after login cover the code side: never build redirectTo from a query parameter without checking it against your own list.
One more detail: if you use redirectTo, Supabase’s docs say you may need to replace {{ .SiteURL }} with {{ .RedirectTo }} in your e-mail templates, or the links ignore it.
4. A password reset that never asks for a password
The reset flow has two halves. First the app calls resetPasswordForEmail with a redirectTo that, per Supabase’s docs, should point to a change password page. When the user clicks the link, they arrive signed in on that page, enter a new password, and the page calls updateUser.
// 1. "Forgot password" form
await supabase.auth.resetPasswordForEmail(email, {
redirectTo: "https://your-app.example/account/update-password",
});
// 2. On /account/update-password, after the link signed the user in
await supabase.auth.updateUser({ password: newPassword });Two pitfalls show up in AI-built apps again and again:
- The link lands on the home page. The user is signed in through the link, sees the dashboard and never sets a new password, so the old one, forgotten or possibly compromised, stays valid.
- The settings page changes passwords without the old one. A “change password” form for signed-in users that only calls
updateUser({ password })lets anyone at an unlocked laptop take over the account. Supabase’s docs show an optionalcurrent_passwordparameter (supabase-js 2.102.0 and later) for exactly this case.
5. Telling strangers which e-mails have accounts
E-mail enumeration means an attacker can find out whether an address is registered, which helps targeted phishing and password guessing. Supabase avoids it where it can: resetPasswordForEmail doesn’t reveal whether an account exists and returns without an error either way, and sign-up for an existing account may return an error that hides it.
The leak is usually added on top:
- a sign-up form that says “this e-mail is already registered”,
- a reset form that says “no account found”,
- an extra database function or Edge Function that checks a
profilestable for an e-mail “to give better errors”.
OWASP’s advice is to answer the same way in every case, for example “If that e-mail address is in our database, we will send you an e-mail to reset your password.” The e-mail enumeration fix shows how to word these messages.
6. Anonymous users who count as signed in
Anonymous sign-ins let visitors use your app before they register. Supabase’s docs are clear about the side effect: an anonymous user gets the authenticated role, just like a permanent user. The difference is the is_anonymous claim in their token. Supabase also advises reviewing your existing RLS policies before you enable the feature, and turning on CAPTCHA or Turnstile against abuse.
So a policy like for insert to authenticated with check ((select auth.uid()) = user_id) lets guests post. Supabase recommends a restrictive policy for the anonymous check, because permissive policies are combined with OR and another policy could otherwise let guests through:
create policy "Only permanent users can post"
on public.posts
as restrictive
for insert
to authenticated
with check ((select (auth.jwt() ->> 'is_anonymous')::boolean) is false);A restrictive policy only narrows what other policies allow, so you still need your normal permissive insert policy. Two details from testing: is false also blocks a token without the claim, which errs on the safe side, and a guest who links an e-mail stays “anonymous” in their token until the session refreshes. Supabase documents a variant that reads auth.users through a helper function if that delay matters to you. Our guide on testing RLS policies shows how to try the policy as each kind of user.
A fix prompt for your AI builder
Review the authentication code in this project that uses Supabase Auth.
- Find every call that passes redirectTo or emailRedirectTo. Make sure the value is a fixed URL on our own domain, never taken from a query parameter or user input without checking it against a hard-coded list.
- Make sure resetPasswordForEmail redirects to a dedicated page that asks for a new password and calls supabase.auth.updateUser with the new password. The home page must not be the reset target.
- On the account settings page, require the current password before changing it (updateUser with current_password, supabase-js 2.102.0 or later).
- Make sign-up, login and reset messages identical whether or not the account exists. Remove any code that looks up whether an e-mail is registered.
- If anonymous sign-ins are used, list every RLS policy for the authenticated role that allows insert, update or delete, and propose a restrictive policy that requires (select (auth.jwt() ->> ‘is_anonymous’)::boolean) is false where guests must not write.
Then list the dashboard settings I should check by hand: Confirm email, Site URL and the Redirect URLs allow list.
Frequently asked questions
Why do my Supabase confirmation e-mails link to localhost:3000?
The Site URL in Authentication → URL Configuration is still the default http://localhost:3000. It is the redirect used when your code passes no redirectTo. Set it to your production URL.
Is it safe to turn off e-mail confirmation in Supabase?
It makes sign-up easier, but then nobody proves they own the address: turning it off marks every new e-mail as confirmed. Never base access on an e-mail address or domain in that case. On hosted projects confirmation is on by default; keep it on for anything that matters.
Why does my password reset link just log the user in?
The reset link signs the user in and then redirects. If redirectTo points to your home page, the user is signed in but never asked for a new password. Point it to a dedicated page that collects the new password and calls updateUser.
Do anonymous users count as authenticated in RLS?
Yes. Supabase gives anonymous users the authenticated role, the same as permanent users. A policy written for authenticated lets guests in too. Tell them apart with the is_anonymous claim, ideally in a restrictive policy.
Does Supabase reveal whether an e-mail address is registered?
Supabase’s password reset does not: it returns without an error whether or not the account exists. Sign-up may also return an error that hides it. The usual leak is your own UI or an extra endpoint that says ‘no account with this e-mail’.
Sources
- 1.Redirect URLs — Supabase Docs
- 2.Password-based Auth — Supabase Docs
- 3.General configuration — Supabase Docs
- 4.Anonymous Sign-Ins — Supabase Docs
- 5.Restrict anonymous user access — Supabase Docs
- 6.JavaScript reference: signUp — Supabase Docs
- 7.Authentication Cheat Sheet — OWASP Cheat Sheet Series