Supabase CORS errors from browser fix

Browser blocks requests due to missing CORS headers in Supabase config. Enable CORS in project settings and configure allowed origins.

Cause

Supabase API requests from browsers fail with CORS (Cross-Origin Resource Sharing) errors when your project's CORS settings don't include your domain.

``` Access to XMLHttpRequest at 'https://your-project.supabase.co/rest/v1/...' from origin 'http://localhost:3000' has been blocked by CORS policy ```

Quick Fix

1. Go to Supabase Dashboard → Your Project → SettingsAPI 2. Scroll to CORS Configuration 3. Add your domain to allowed origins: - Development: http://localhost:3000 - Production: https://yourdomain.com 4. Save changes (takes 30 seconds to propagate)

```javascript // Verify it works const { data, error } = await supabase .from('your_table') .select('*'); ```

Prevention

Configure properly from start:

1. Use environment variables for your Supabase URL/key: ```javascript const supabase = createClient( process.env.REACT_APP_SUPABASE_URL, process.env.REACT_APP_SUPABASE_ANON_KEY ); ```

2. Add all environments to CORS: - http://localhost:3000 (dev) - http://localhost:5173 (Vite dev) - https://yourdomain.com (prod) - https://staging.yourdomain.com (staging)

3. Use wildcards carefully (not recommended for production): ``` http://localhost:* (localhost any port) https://*.yourdomain.com (subdomains) ```

4. Check browser console for exact origin: ```javascript console.log(window.location.origin); // Copy-paste exact value to CORS settings ```

Common gotchas:

  • Protocol matters: http://https://
  • Port matters: localhost:3000localhost:5173
  • Trailing slashes: don't add them
  • Changes take ~30 seconds to apply (refresh page)
  • For mobile/Expo apps: Supabase is accessible from native apps without CORS issues since they don't use browsers.

    🔥 0d
    LIVE
    PlanetScale rage spiking Vercel pricing complaints Railway gaining fast Supabase happiness rising Resend loved by devs PlanetScale rage spiking Vercel pricing complaints Railway gaining fast Supabase happiness rising
    DEVELOPER PAIN RADAR // Loading...

    Developers complain.
    Opportunities appear.

    We track what developers are struggling with today — and what opportunities that creates.

    guides today
    avg happiness
    🔥 Pain
    📖 Guides
    🔭 Explore
    👤 Mine
    🔥 Pain Radar — rage scores today
    ↗ share
    💡 Opportunity Feed — pain = market gap
    📈 Tool Momentum
    all scores →
    📖 Latest Guide
    all guides →
    📖 All Guides
    📊 Tool Scores
    + Submit
    📰 Hacker News
    ➕ Submit a Tool
    ← back