Supabase redirect URL wildcards: the safe pattern
In Supabase's Redirect URLs list, * matches any run of characters except . and /, and ** matches everything, separators included. That makes https://*.vercel.app/** or https://** an allow-list that accepts other people's sites. List your production callback URLs exactly, scope preview patterns to a domain you control, and keep ** for paths on localhost.
The Redirect URLs list (Authentication → URL Configuration, or additional_redirect_urls in supabase/config.toml) decides where Supabase may send a user after a magic link, an OAuth sign-in, an email confirmation or a password reset. Whatever URL passes that check receives the session, as tokens in the URL fragment with the implicit flow or as a one-time code with PKCE. A wildcard that matches too much hands that session to whoever owns the matching URL.
How do Supabase redirect URL wildcards work?
Supabase matches each redirectTo against your list as a glob over the whole URL, scheme and host included. The redirect URL docs define the syntax:
*"matches any sequence of non-separator characters"**"matches any sequence of characters"?"matches any single non-separator character"- "The separator characters in a URL are defined as
.and/."
The auth server compiles each entry with exactly those two separators (glob.MustCompile(uri, '.', '/') in supabase/auth's configuration.go). Matching ignores anything after #.
Two consequences matter for security. * crosses hyphens, so *-myteam matches evil-myteam. And ** crosses dots, so ** anywhere in the host matches any domain you can imagine.
| Entry | Matches | Risk |
|---|---|---|
https://app.example.com/auth/callback | that URL (any path on your Site URL host passes anyway) | none |
https://app.example.com/** | any path on your host | low: any page on your own host can receive the session |
http://localhost:3000/** | local dev | none |
https://*-myteam.vercel.app/** | your previews, and any vercel.app host ending in -myteam | depends on who can claim such a host |
https://*.vercel.app/** | every project on Vercel | anyone can deploy there |
https://app.example.com** | also https://app.example.com.attacker.net/ | ** crossed the dot |
https://** | every HTTPS URL | none of the list is left |
One exception sits before the list: IsRedirectURLValid accepts any URL whose scheme, host and port match your Site URL (the port check is skipped for localhost) without consulting the list at all. Every path on your Site URL's host is already allowed.
Why does a wide wildcard matter?
The caller chooses redirectTo, and the caller can be anyone. Supabase's sign-in calls take it from the request:
// run from any browser, with your public URL and publishable key
await supabase.auth.signInWithOtp({
email: "victim@example.com",
options: { emailRedirectTo: "https://evil-myteam.vercel.app/grab" },
});
If that URL passes your list, the victim gets a genuine email from your project. They click it, Supabase verifies the token, and the browser lands on the attacker's page with the session attached. With the implicit flow, the access and refresh tokens sit in the URL fragment, which the page's own JavaScript can read. With PKCE it's a one-time code, and what an attacker can do with it depends on who holds the code verifier. We haven't run a full exchange end to end, so treat the PKCE case as "an auth code delivered to a host you don't control", not a proven takeover. resetPasswordForEmail and signInWithOAuth take a redirect too.
When redirectTo doesn't match, nothing breaks loudly. The server's GetReferrer in request.go checks the redirect_to value, then the Referer header, and otherwise returns your Site URL. That fallback is why people see "supabase redirect url not working" (users land on the homepage instead of /auth/callback) and why the quick fix is so often a broader wildcard.
The Vercel preview pattern, and its edge
Supabase's docs recommend https://*-<team-or-account-slug>.vercel.app/** for preview deployments, because a Vercel preview URL looks like <project>-<hash>-<team-slug>.vercel.app. It's a reasonable trade, but know where its edge is: * matches everything up to the suffix, hyphens included, so the entry also accepts any vercel.app hostname that happens to end in -<team-slug>. Whether someone else can get such a hostname depends on how Vercel hands out names, which you don't control.
In stonghuuloc/chaiyo#9 (merged October 28, 2026), the project added this to supabase/config.toml:
"https://chaiyo-*-stonghuulocs-projects.vercel.app/**"
An automated reviewer pointed out that it "also accepts a hostname such as chaiyo-HASH-evil-stonghuulocs-projects.vercel.app". The author accepted the risk on purpose, and the PR body says it plainly: "Another Vercel team with a slug ending -stonghuulocs-projects would also match." That's a fair call for a hobby project if it's made knowingly. If you have this entry, make the same call on purpose.
How do I set Supabase redirect URLs safely?
Use exact URLs where you can and a wildcard only where you own every host it can match.
# supabase/config.toml
[auth]
site_url = "https://app.example.com"
additional_redirect_urls = [
"https://app.example.com/auth/callback",
"https://app.example.com/auth/confirm",
"http://localhost:3000/**",
# previews on a domain you own: every match is yours
"https://*.preview.example.com/auth/callback",
]
- Production: exact paths. The docs say it directly: "we recommend setting the exact redirect URL path for your site URL in production." Three or four entries is normal. Supabase accepts any path on the Site URL's host even unlisted, so exact entries matter most for other hosts, and your callback's own redirect logic (step 5) is what protects that host.
- Previews: a domain you own. If your host can serve previews from subdomains of a domain you own, like
*.preview.example.com, then*can only match hosts you control. If you stay onvercel.app, use the team-slug pattern, never bare*.vercel.app. - Keep
**after a slash.https://app.example.com/**stays on your host.https://app.example.com**does not. - Localhost can be broad.
http://localhost:3000/**only matches your own machine. - Read your callback's
nextparameter. An exact callback that then redirects to?next=without checking it is the same leak one hop later. That's the open redirect thatstartsWith('/')doesn't stop.
The dashboard and config.toml are separate. config.toml applies to the local stack, and to a hosted project only when you push config with the CLI, so check both. If you widened this list to get past a PKCE error, the real cause was probably elsewhere. Invalid flow state and auth code and code verifier should be non-empty cover the callback-side causes.
Quick self-check
# every redirect entry in your repo
grep -rn "additional_redirect_urls" -A12 supabase/config.toml
# entries that match other people's hosts
grep -nE '"https?://\*\*|\*\.vercel\.app|\*\.netlify\.app|\.(com|app|dev|io)\*\*' supabase/config.toml
Then open Authentication → URL Configuration in the dashboard and read the list. Any entry where ** comes before the first / after the host, any bare *.vercel.app or *.netlify.app, and any https://** should go.
Does GuardLayer catch this?
No, not today. GuardLayer doesn't read supabase/config.toml redirect entries yet, and the dashboard list lives outside your repo. Use the grep above. GuardLayer does flag the open-redirect half in your own code (nextjs/open-redirect), and the Next.js + Supabase security checklist covers that open-redirect side in your own code.
FAQ
Does Supabase support wildcards in redirect URLs?
Yes. * matches characters other than . and /, ** matches anything, and ? matches one non-separator character. They apply to the whole URL, host included.
Why does Supabase redirect to my Site URL instead of my redirectTo?
Because redirectTo didn't match any entry. The auth server then tries the Referer header and finally falls back to the Site URL, without an error. Any URL on the Site URL's own host passes without a list entry.
Is https://*.vercel.app/** safe?
No. It matches every project anyone deploys on Vercel. Use your team-slug pattern or, better, a preview domain you own.
What's the difference between * and **?
* stops at a dot or slash, so it matches one hostname label or one path segment. ** keeps going across both.
Should I use ** in production?
Only after a slash on your own host, and preferably not at all. Supabase recommends exact redirect paths for your production site.
Check your Supabase Auth settings and tables, free
Connect your Supabase project read-only. GuardLayer checks your Auth settings (leaked passwords, email confirmation, secure email change, token rotation, CAPTCHA, MFA) and your RLS, policies and grants, and says how to fix each problem. It never reads your rows and can't change anything.
Check my Supabase projectPrefer to check code instead? Scan your repo, no signup.