Environment Variables Overview
Echoes of the Past requires several environment variables to function properly. These variables configure integrations with Supabase, Vapi AI, ElevenLabs, OpenAI, and Redis.Never commit environment variables to version control. Create a
.env.local file in the project root and add it to .gitignore.Create Environment File
Create a.env.local file in the root of your project:
Required Environment Variables
Supabase Configuration
Supabase is used for database, authentication, and file storage..env.local
Create a Supabase Project
- Go to supabase.com and sign in
- Click “New Project” and fill in the details
- Wait for the project to be provisioned
The project is currently configured to use project ID
fmknwbbacrndtinyyhiw for type generation. You can update this in package.json under the gen-types script.Vapi AI Configuration
Vapi AI powers the voice conversation functionality..env.local
Sign Up for Vapi AI
- Visit vapi.ai and create an account
- Complete the onboarding process
This variable is required and the application will throw an error if it’s not set (see
lib/vapi.ts:3).ElevenLabs Configuration
ElevenLabs provides text-to-speech functionality for historical figure voices..env.local
Create ElevenLabs Account
- Go to elevenlabs.io and sign up
- Choose a plan (free tier available)
OpenAI Configuration
OpenAI is used for AI-powered conversation and content generation..env.local
Get OpenAI API Key
- Visit platform.openai.com
- Sign in or create an account
- Navigate to API Keys section
- Click “Create new secret key”
- Copy the key immediately (it won’t be shown again)
This variable is required and the application will throw an error if it’s not set (see
lib/ai.ts:3).Upstash Redis Configuration
Redis is used for rate limiting and caching..env.local
Create Upstash Database
- Go to upstash.com and sign in
- Click “Create Database”
- Choose a name and region
- Select the free tier
Both variables are required and the application will throw an error if either is missing (see
lib/redis.ts:3).Application URL Configuration
These variables configure URLs for authentication callbacks and webhooks..env.local
NEXT_PUBLIC_APP_URL: Used for OAuth redirects (seefeatures/auth/components/sign-in-google-btn.tsx:21)NEXT_PUBLIC_SERVER_URL: Used for webhook URLs (seefeatures/call/hooks/useVapi.ts:57)
In production, update these to your deployed URL (e.g.,
https://your-app.vercel.app).Optional: Vercel Configuration
When deploying to Vercel, this variable is automatically set:.env.local
config/metadata.ts:5).
Complete Environment File Example
Here’s a complete.env.local template:
.env.local
Validating Your Configuration
After setting up your environment variables, verify they’re loaded correctly:-
Start the development server:
-
Check for any error messages in the console. The application validates required environment variables at startup:
lib/vapi.tschecks forNEXT_PUBLIC_VAPI_WEB_TOKENlib/ai.tschecks forOPENAI_API_KEYlib/redis.tschecks for Redis credentialsnext.config.tschecks forNEXT_PUBLIC_SUPABASE_URL
-
If all variables are set correctly, you should see:
Environment-Specific Configuration
Development
UseNODE_ENV=development for local development. This enables:
- Detailed error messages
- React Query DevTools
- Hot module replacement
Production
For production deployments:- Set
NODE_ENV=production - Update URLs to production domains
- Enable analytics (see
app/layout.tsx:43) - Use production API keys (not test keys)
Next Steps
Once your environment is configured:Set Up Database
Configure your Supabase database and run migrations. See Database Setup.
Troubleshooting
Environment Variables Not Loading
If your environment variables aren’t being recognized:- Ensure the file is named exactly
.env.local - Restart your development server
- Check for typos in variable names
- Verify the file is in the project root
CORS Errors with Supabase
If you encounter CORS errors:- Verify your
NEXT_PUBLIC_APP_URLmatches your development URL - Check Supabase dashboard Authentication > URL Configuration
- Add
http://localhost:3000to allowed redirect URLs
API Rate Limits
During development:- OpenAI and ElevenLabs have rate limits on free tiers
- Consider using test/development API keys
- Redis caching helps reduce API calls