Production Fix

Supabase Auth Works in
Preview But Breaks in Production?

The #1 reason auth fails after deployment. Learn the 4 configuration changes that fix 90% of production auth issues.

Quick Fix Checklist:
1. Update Supabase callback URLs
2. Configure CORS origins
3. Set production env variables
4. Verify RLS policies

See Full Fix Guide Get Expert Help ($299)

Fixes auth for Vercel, Netlify, and custom domains • Used by 300+ deployed apps

The Auth Gap

Works in Bolt preview
Deploy to Vercel/Netlify
Auth redirects fail
Users can't log in

Fix in 15 minutes

The Complete Fix

4 Steps to Fix Production Auth

Follow these in order. Each step fixes a different layer of the auth stack.

1

Update Supabase Callback URLs

The Problem: Supabase doesn't know your production domain exists, so auth redirects fail or go to the wrong URL.

The Fix:

  1. Go to Supabase Dashboard → Authentication → URL Configuration
  2. Update Site URL to your production domain (e.g., https://yourapp.vercel.app)
  3. Add your domain to Redirect URLs (whitelist)
  4. Include both www and non-www versions if applicable
  5. Add localhost:5173 for local development testing

Example Redirect URLs:

https://yourapp.vercel.app
https://yourapp.vercel.app/auth/callback
http://localhost:5173
http://localhost:5173/auth/callback

Result: Auth redirects now go to your actual production domain instead of failing.

2

Configure CORS Origins

The Problem: Browser blocks requests because your production domain isn't whitelisted in Supabase CORS settings.

The Fix:

  1. Go to Supabase Dashboard → Database → API
  2. Scroll to "CORS Origins" section
  3. Add your production domain: https://yourapp.vercel.app
  4. Add localhost for development: http://localhost:5173
  5. Save changes (takes 1-2 minutes to propagate)

Warning: Using * (allow all) in CORS is insecure for production. Always specify exact domains.

3

Set Production Environment Variables

The Problem: Your deployment platform doesn't have the Supabase keys, or they're pointing to the wrong project.

The Fix:

Add these to your Vercel/Netlify dashboard:

VITE_SUPABASE_URL=https://yourproject.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key_here
  • Find these in Supabase Dashboard → Settings → API
  • Use the anon public key (not the service_role key)
  • Verify the URL matches your project
  • Redeploy after adding variables

Result: App can connect to Supabase API from your production domain.

4

Check Row Level Security (RLS) Policies

The Problem: Database queries return empty results or 403 errors because RLS policies block production requests.

The Fix:

  1. Go to Supabase Dashboard → Database → Tables
  2. Click on your auth/user table
  3. Go to "Policies" tab
  4. Check if RLS is enabled (it should be for security)
  5. Verify policies allow authenticated users to read their own data
  6. Add policies if missing (see example below)

Example RLS Policy:

CREATE POLICY "Users can read own data"
ON public.users
FOR SELECT
USING (auth.uid() = id);

Note: Disabling RLS "fixes" auth but removes all security. Always use proper policies instead.

Debug Tool

Auth Debug Checklist

Run through this when auth still doesn't work after the 4 steps above.

Quick Diagnostic Steps

Most Common Error: If you see CORS error or 403 Forbidden, your CORS origins or callback URLs are misconfigured. Go back to Steps 1 & 2.

Platform-Specific Notes

Vercel Deployment

  • Environment variables: Project Settings → Environment Variables
  • Add both Production and Preview environment variables
  • Redeploy after changing env vars (they don't auto-update)
  • Preview deployments need separate Supabase config if using branch-based URLs

Netlify Deployment

  • Environment variables: Site Settings → Environment
  • Use "Edit variables" to add Supabase keys
  • Trigger new deploy after adding variables
  • Check Functions tab if using Netlify Functions for auth

Auth Still Broken?

Some auth issues require deeper debugging: custom providers, edge functions, complex RLS policies, or session handling. Get expert help to identify the root cause.

Book Auth Audit ($299) Get Free Fix Guide

Includes: Full auth flow analysis, RLS policy review, deployment configuration audit, and working fix within 48 hours.