Symptom: auth breaks on custom domain: Supabase Auth / Clerk redirect and cookie mismatch
The auth provider is still configured for your old origin, so it redirects to localhost or sets cookies for a domain your app no longer uses. In Supabase, set the Site URL and Redirect URLs to your custom domain; in Clerk, create a production instance for that domain and add its DNS records.
Cause: Site URL / allowed redirect URLs / production domain still point at localhost or the preview domain.
How to fix it
- Supabase: Authentication > URL Configuration: set Site URL to
https://yourdomain.comand add production redirect URLs. - Pass
redirectTothat matches an allowed URL (e.g.window.location.origin). - Clerk: create a production instance, add your domain and the DNS records Clerk shows, and use production keys.
- Update OAuth provider callback URLs and redeploy with the new env vars.
Example
Illustrative example, not from a customer project.
// Supabase sign-in
await supabase.auth.signInWithOAuth({
provider: 'google',
- options: { redirectTo: 'http://localhost:3000' },
+ options: { redirectTo: `${window.location.origin}/auth/callback` },
})
FAQ
Why localhost specifically?
Supabase falls back to the Site URL, which defaults to localhost in new projects, when redirectTo isn't an allowed URL.
Can I use Clerk development keys in production?
Clerk's docs direct you to a production instance with your own domain for launch.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- Read-only access; fixes arrive as pull requests you merge.
- Your $149 diagnosis is credited in full toward any paid job.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: More than one auth or data issue? Auth & database security fix, from $400.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.