Required Environment Variables
Your Supabase project URL. Format:
https://[project-ref].supabase.coExample: https://vcssfbdprqmpmuhwaapb.supabase.coThe anonymous (public) key for your Supabase project. This key is safe to use in client-side code and respects Row Level Security policies.Find this in your Supabase project dashboard under Settings → API.
The service role key for server-side operations that bypass Row Level Security. Keep this secret - never expose it to the client.Alternative names supported:
SUPABASE_SERVICE_ROLE_KEYComma-separated list of email addresses to grant admin access, bypassing the
usuarios.rol check.Example: admin@company.com,superadmin@company.comUsed by the /api/auth-sync serverless function to whitelist administrators.Client-Side Variables (Vercel)
When deploying to Vercel or similar platforms, you can prefix environment variables withNEXT_PUBLIC_ to make them available in the client bundle:
Client-accessible Supabase URL (alternative to
SUPABASE_URL)Client-accessible anonymous key (alternative to
SUPABASE_ANON_KEY)The application automatically falls back between
NEXT_PUBLIC_* prefixed variables and regular environment variables. See supabaseClient.js:14-22 for implementation details.Environment Variable Priority
The Supabase client initialization follows this priority order:- Process environment variables -
process.env.NEXT_PUBLIC_SUPABASE_URL - Window globals -
window.SUPABASE_URL(for local development) - Hardcoded fallbacks - Development defaults (only for development)
Development Setup
For local development, create a.env.local file in the frontend directory:
.env.local
Production Setup
Vercel
Set environment variables in the Vercel dashboard:- Go to Project Settings → Environment Variables
- Add each variable for Production, Preview, and Development environments
- Click Save
Other Platforms
For Netlify, Railway, or other platforms, refer to their documentation for setting environment variables:- Netlify: Site Settings → Build & Deploy → Environment
- Railway: Project Settings → Variables
- Render: Environment → Environment Variables
Validation
The application validates the Supabase connection on initialization:Troubleshooting
Error: Supabase env vars missing
Error: Supabase env vars missing
This error occurs when serverless functions cannot find required environment variables.Solution: Ensure
SUPABASE_URL, SUPABASE_ANON_KEY, and SUPABASE_SERVICE_KEY (or SUPABASE_SERVICE_ROLE_KEY) are set in your deployment environment.Error: Supabase CDN no cargado
Error: Supabase CDN no cargado
The Supabase JavaScript SDK is not loaded from the CDN.Solution: Verify that
index.html includes the Supabase CDN script:401 Unauthorized in API calls
401 Unauthorized in API calls
