This page documents all environment variables required for the Sabbels Handmade e-commerce application.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aluxey/E-Commerce/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The application has two environments:- Client (React/Vite frontend)
- API (Express backend)
Client Environment Variables
Location:/client/.env.local
Vite requires all client-side environment variables to be prefixed with
VITE_.Supabase Configuration
Your Supabase project URL.Where to find: Supabase Dashboard → Project Settings → API → Project URLExample:
https://abcdefghijklm.supabase.coUsed in: /client/src/supabase/supabaseClient.js:3Your Supabase anonymous (public) key.Where to find: Supabase Dashboard → Project Settings → API → Project API keys →
anon publicExample: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...Used in: /client/src/supabase/supabaseClient.js:5-6Legacy name for
VITE_SUPABASE_ANON_KEY.Status: Deprecated but still supported for backward compatibility.Migration: Use VITE_SUPABASE_ANON_KEY instead.API Configuration
Base URL for your API server.Development:
http://localhost:3000Production: https://your-api.example.comExample: http://localhost:3000Do not include trailing slash or
/api path. The client adds these automatically.Example Client .env.local
API Environment Variables
Location:/api/.env
Server Configuration
Port number for the API server.Default:
3000Example: 3000Used in: /api/src/server.js:8Most deployment platforms set this automatically (Heroku, Railway, Render).
Environment mode.Options:
development | productionDefault: developmentUsed in: /api/src/server.js:132 (CORS configuration)In development mode, CORS allows all origins. In production, only
CLIENT_ORIGIN is allowed.Comma-separated list of allowed client URLs for CORS.Example:
https://sabbelshandmade.netlify.app,https://sabbelshandmade.comUsed in: /api/src/server.js:9Multiple origins can be separated by commas. Whitespace is automatically trimmed.
Supabase Configuration
Your Supabase project URL.Where to find: Supabase Dashboard → Project Settings → API → Project URLExample:
https://abcdefghijklm.supabase.coUsed in: /api/src/server.js:12Your Supabase service role key for admin access.Where to find: Supabase Dashboard → Project Settings → API → Project API keys →
service_role secretExample: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...Used in: /api/src/server.js:13,24Stripe Configuration
Your Stripe secret key for server-side operations.Where to find: Stripe Dashboard → Developers → API keys → Secret keyTest mode:
sk_test_...Live mode: sk_live_...Example: sk_test_51Ab3CdEfGhIjKlMnOpQrStUvWxYz...Used in: /api/src/server.js:10,23Webhook signing secret for verifying Stripe events.Where to find: Stripe Dashboard → Developers → Webhooks → [Your endpoint] → Signing secretExample:
whsec_abcdef1234567890...Used in: /api/src/server.js:11,42For local testing with Stripe CLI: Run
stripe listen --forward-to localhost:3000/api/stripe/webhook and use the provided webhook secret.Email Configuration
Resend API key for sending transactional emails.Where to find: Resend Dashboard → API KeysExample:
re_abcdef123456_7890ghijklmnopqrstuvwxyzUsed in: /api/src/server.js:16,27If not set, emails are logged to console instead of being sent. Useful for local development.
Example API .env
Security Best Practices
Add to .gitignore
Ensure these files are in your.gitignore:
Use Different Keys per Environment
| Environment | Stripe | Supabase | Resend |
|---|---|---|---|
| Development | Test keys (sk_test_, pk_test_) | Dev project | Test API key |
| Staging | Test keys | Staging project | Staging domain |
| Production | Live keys (sk_live_, pk_live_) | Production project | Production domain |
Rotate Keys Regularly
If a key is exposed:- Immediately revoke it in the service dashboard
- Generate a new key
- Update environment variables
- Redeploy applications
Use Secret Management
For production:- Netlify: Environment variables in site settings
- Vercel: Environment variables in project settings
- Railway: Environment variables in deployment settings
- Heroku: Config vars in app settings
Validation
Both client and server validate required environment variables on startup.Client Validation
Code reference:/client/src/supabase/supabaseClient.js:8-17
Server Validation
Code reference:/api/src/server.js:19-21
Deployment Environments
Netlify (Client)
- Go to Site settings → Build & deploy → Environment
- Add variables:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYVITE_API_BASE_URL
- Redeploy site
Railway (API)
- Go to your project → Variables
- Add variables from API section
- Railway auto-redeploys on variable changes
Heroku (API)
- Go to Settings → Config Vars
- Add each variable
Troubleshooting
”Missing required environment variables”
Client: Check browser console for specific missing variables. Server: Check server logs on startup.Variables Not Loading
Vite (Client):- Ensure variables start with
VITE_ - Restart dev server after adding variables
- Check file is named
.env.local(not.env)
- If using
--env-fileflag: Ensure file path is correct - If using
dotenv: Ensurerequire('dotenv').config()is called - Restart server after changes
CORS Errors in Production
CLIENT_ORIGIN:
Stripe Webhooks Failing
- Wrong
STRIPE_WEBHOOK_SECRETfor the environment - Using local webhook secret in production
- Using production webhook secret locally
- Local: Use Stripe CLI webhook secret
- Production: Use webhook endpoint secret from Stripe Dashboard