Overview
The Transport Logistics platform uses environment variables to configure connections to external services, primarily Supabase for backend functionality.Current Configuration
Supabase Client Setup
The Supabase client is configured insrc/integrations/supabase/client.ts:
The file is marked as auto-generated with a warning not to edit directly. This suggests it may be managed by a build tool or deployment platform.
Recommended Environment Variables
For a production-ready setup, migrate to environment variables:Required Variables
Your Supabase project URLFormat:
https://[project-ref].supabase.coExample: https://uvosmrargaueilecbycn.supabase.coWhere to find: Supabase Dashboard → Project Settings → API → Project URLYour Supabase anonymous (publishable) keyFormat: Long JWT token starting with
eyJ...Security: Safe to expose in client-side code (public key)Where to find: Supabase Dashboard → Project Settings → API → Project API keys → anon publicOptional Variables
Service role key for admin operations (server-side only)Security: ⚠️ Never expose in client code - has full database accessUse case: Backend scripts, migrations, admin functions
Base URL for API requests if using a separate backend
Application environmentOptions:
development, staging, productionSetup Instructions
Create Environment File
Create a
.env.local file in the project root:Vite only loads
.env files that start with VITE_ prefix for security. Variables without this prefix won’t be exposed to the client.Getting Supabase Credentials
Access Supabase Dashboard
Log in to your Supabase Dashboard
Environment Files
Vite supports multiple environment files:Load Priority
Vite loads environment files in this order (higher priority first):.env.[mode].local(e.g.,.env.production.local).env.[mode](e.g.,.env.production).env.local.env
Accessing Environment Variables
In your TypeScript/JavaScript code:Built-in Vite Variables
Vite provides these variables automatically:The mode the app is running in (
development, production, etc.)true if running in development modetrue if running in production modeThe base URL the app is being served from
Security Best Practices
Never Commit Secrets
Add
.env.local and .env.*.local to .gitignoreUse VITE_ Prefix
Only variables with
VITE_ prefix are exposed to clientRotate Keys Regularly
Change API keys periodically in Supabase dashboard
Separate Service Keys
Never expose service role keys in client code
Deployment
When deploying to production platforms:- Vercel
- Netlify
- Docker
Add environment variables in Project Settings → Environment Variables:Redeploy to apply changes.
Troubleshooting
Environment variables are undefined
Environment variables are undefined
Possible causes:
- Missing
VITE_prefix (variables must start withVITE_) - Server not restarted after adding variables
- Typo in variable name
.env.localfile not in project root
npm run devSupabase connection fails
Supabase connection fails
Check:
- URL format is correct:
https://[project-ref].supabase.co - No trailing slashes in URL
- Anon key is complete (long JWT token)
- Project is not paused in Supabase dashboard
- Network connectivity to Supabase servers
Variables work locally but not in production
Variables work locally but not in production
Verify:
- Environment variables are set in hosting platform
- Build was triggered after adding variables
- Variable names match exactly (case-sensitive)
- No quotes around values in hosting platform
Next Steps
Database Migrations
Learn how to manage database schema changes
Local Setup
Complete local development setup guide