Environment Variables
Catafract requires several environment variables to be configured. Create a.env.local file in the project root with the following variables.
Required Variables
Authentication
string
required
Google OAuth Client ID from Google Cloud ConsoleHow to get:
- Go to Google Cloud Console
- Navigate to APIs & Services > Credentials
- Create OAuth 2.0 Client ID
- Copy the Client ID
string
required
Google OAuth Client Secret from Google Cloud ConsoleHow to get:
Available in the same location as Client ID
string
required
The base URL of your applicationDevelopment:Production:
string
required
Secret key for encrypting session tokensGenerate with:Example:
abc123xyz789...Azure Storage
string
required
Connection string for Azure Blob StorageFormat:How to get:
- Go to Azure Portal
- Navigate to your Storage Account
- Go to Access Keys
- Copy Connection String
string
required
Connection string for Azure Cosmos DBFormat:How to get:
- Go to Azure Portal
- Navigate to your Cosmos DB account
- Go to Keys
- Copy Primary Connection String
AI Model
string
required
API key for Google Gemini AIHow to get:
- Go to Google AI Studio
- Create API Key
- Copy the key
Optional Variables
Payment Processing (Polar)
string
Environment mode for Polar integrationValues:
local- Use sandbox modeproduction- Use production mode
productionstring
Polar production access tokenHow to get:
- Sign up at Polar.sh
- Go to Settings > API Keys
- Create Production Access Token
string
Polar sandbox access token for testingHow to get:
Same as production token, but select Sandbox mode
string
Secret for verifying Polar webhooks (production)How to get:
- Go to Polar Settings > Webhooks
- Create webhook endpoint
- Copy the signing secret
string
Secret for verifying Polar webhooks (sandbox)
string
URL to redirect after successful paymentExample:
string
URL to return from customer portalExample:
Video Processing (Mux)
string
Mux API Token IDHow to get:
- Sign up at Mux
- Go to Settings > Access Tokens
- Create new token
- Copy Token ID
string
Mux API Token SecretHow to get:
Available when creating the token (copy immediately, not shown again)
Analytics (Mixpanel)
string
Mixpanel project tokenHow to get:
- Sign up at Mixpanel
- Create a project
- Go to Project Settings
- Copy Project Token
NEXT_PUBLIC_ to be available client-sidestring
Custom proxy URL for Mixpanel API (optional)Use case: Bypass ad blockers or implement custom trackingDefault: Mixpanel’s default API endpoint
Complete Example
Azure Configuration
Required Azure Resources
-
Storage Account
- Container name:
catafract - Public access level: Blob (anonymous read access)
- Container name:
-
Cosmos DB Account
- API: Core (SQL)
- Database name:
catafract - Containers:
users(partition key:/email)projects(partition key:/userId)canvas(partition key:/projectId)generations(partition key:/userId)
Creating Azure Resources
Validation
To validate your configuration, run:Security Best Practices
- Never commit
.env.localto version control - Add
.env.localto.gitignore - Use different credentials for development and production
- Rotate secrets regularly
- Use Azure Key Vault for production secrets
- Enable Azure Storage firewall rules
- Implement IP restrictions on Cosmos DB
- Monitor API usage and set up alerts