Supabase Environment Variables Setup Guide¶
Problem¶
The frontend requires VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY at build time (not runtime). If these are missing during the build, the application will fail with:
Solution¶
For GitHub Actions (Hostinger Deployment) ✅ FIXED¶
The workflow has been updated to include these variables. You need to add them as GitHub Secrets:
- Go to your GitHub repository:
https://github.com/magiccadai/AI-assisted-PCB-stackup-generator - Click Settings → Secrets and variables → Actions
- Click New repository secret and add:
Secret 1:
- Name: VITE_SUPABASE_URL
- Value: https://orjmlibnlzkyuauaysye.supabase.co (or your Supabase URL)
Secret 2:
- Name: VITE_SUPABASE_ANON_KEY
- Value: Your Supabase anonymous key (from Supabase dashboard)
- The workflow will automatically use these during the build
For Render Deployment¶
If you're building the frontend on Render, you need to set these as Environment Variables in your Render dashboard:
- Go to https://dashboard.render.com
- Select your frontend service (if you have one)
- Go to Environment tab
- Add these environment variables:
Variable 1:
- Key: VITE_SUPABASE_URL
- Value: https://orjmlibnlzkyuauaysye.supabase.co
Variable 2:
- Key: VITE_SUPABASE_ANON_KEY
- Value: Your Supabase anonymous key
- Important: After adding variables, you must redeploy the service for them to take effect
For Local Development¶
Create a .env file in the repo-root directory (Vite reads the root .env via envDir: rootDir in frontend/vite.config.ts; a frontend/.env is ignored and is deleted by the start script):
VITE_SUPABASE_URL=https://orjmlibnlzkyuauaysye.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key_here
How to Get Your Supabase Keys¶
- Go to your Supabase project dashboard: https://supabase.com/dashboard
- Select your project
- Go to Settings → API
- Find:
- Project URL → This is your
VITE_SUPABASE_URL - anon/public key → This is your
VITE_SUPABASE_ANON_KEY
Important Notes¶
- ⚠️ Vite environment variables must start with
VITE_to be included in the frontend bundle - ⚠️ These variables are embedded at BUILD TIME, not runtime
- ⚠️ After changing environment variables, you must rebuild/redeploy
- ✅ These are public keys - safe to expose in frontend code (Row Level Security protects your data)
Verification¶
After setting up, verify the build includes the variables:
- Check the build logs for any errors about missing variables
- In the browser console, you should NOT see the error about
VITE_SUPABASE_URL - The Supabase client should initialize successfully