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.
Get a $149 diagnosis See pricing Still exposed or still logged out? Get an auth & database security fix (Supabase, Firebase).
- 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.