Overview
Portal Ciudadano Manta uses environment variables to configure the connection to Supabase backend services.Required Variables
VITE_SUPABASE_URL
Description: Your Supabase project URL Format:https://your-project-id.supabase.co
Example:
- Go to Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the “Project URL”
VITE_SUPABASE_ANON_KEY
Description: Your Supabase anonymous (public) key Format: JWT token string (starts witheyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9)
Example:
- Go to Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the “anon” key under “Project API keys”
The
anon key is safe to use in client-side code. Row Level Security (RLS) policies protect your data.Local Development Setup
Production Configuration
Netlify
Navigate to Site Settings
Go to your site in Netlify dashboard → Site settings → Environment variables
Add Variables
Click “Add a variable” for each:
-
Key:
VITE_SUPABASE_URL - Value: Your Supabase URL
-
Key:
VITE_SUPABASE_ANON_KEY - Value: Your Supabase anon key
Vercel
Navigate to Project Settings
Go to your project in Vercel dashboard → Settings → Environment Variables
Add Variables
For each variable:
- Enter the key name (e.g.,
VITE_SUPABASE_URL) - Enter the value
- Select environments: Production, Preview, Development
- Click “Save”
Environment Validation
The application validates environment variables on startup:src/lib/supabase.ts:6
Using Environment Variables
Access variables in your code usingimport.meta.env:
All client-side environment variables in Vite must be prefixed with
VITE_ to be exposed to your application.Troubleshooting
Variables Not Loading
Problem:import.meta.env.VITE_SUPABASE_URL returns undefined
Solutions:
- Ensure variable names start with
VITE_ - Restart your development server after adding variables
- Check
.envfile is in project root - Verify
.envfile syntax (no spaces around=)
Connection Errors
Problem: “Failed to fetch” or CORS errors Solutions:- Verify URL format is correct (includes
https://) - Check Supabase project is active (not paused)
- Verify API key is the “anon” key, not “service_role”
Authentication Fails
Problem: Users can’t sign up or log in Solutions:- Check Site URL in Supabase Authentication settings
- Add redirect URLs for your domain
- Verify email provider is enabled in Supabase
Security Best Practices
Never Commit
Don’t commit
.env files to version controlUse RLS
Always enable Row Level Security policies
Rotate Keys
Rotate keys if accidentally exposed
Platform Variables
Use platform environment variables in production
Next Steps
Supabase Setup
Complete Supabase configuration
Deploy to Netlify
Deploy with environment variables
