Skip to main content

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:
  1. Go to Google Cloud Console
  2. Navigate to APIs & Services > Credentials
  3. Create OAuth 2.0 Client ID
  4. 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:
  1. Go to Azure Portal
  2. Navigate to your Storage Account
  3. Go to Access Keys
  4. Copy Connection String
string
required
Connection string for Azure Cosmos DBFormat:
How to get:
  1. Go to Azure Portal
  2. Navigate to your Cosmos DB account
  3. Go to Keys
  4. Copy Primary Connection String

AI Model

string
required
API key for Google Gemini AIHow to get:
  1. Go to Google AI Studio
  2. Create API Key
  3. Copy the key
Note: This is different from Google Cloud API keys

Optional Variables

Payment Processing (Polar)

string
Environment mode for Polar integrationValues:
  • local - Use sandbox mode
  • production - Use production mode
Default: production
string
Polar production access tokenHow to get:
  1. Sign up at Polar.sh
  2. Go to Settings > API Keys
  3. 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:
  1. Go to Polar Settings > Webhooks
  2. Create webhook endpoint
  3. 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:
  1. Sign up at Mux
  2. Go to Settings > Access Tokens
  3. Create new token
  4. 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:
  1. Sign up at Mixpanel
  2. Create a project
  3. Go to Project Settings
  4. Copy Project Token
Note: Must be prefixed with NEXT_PUBLIC_ to be available client-side
string
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

  1. Storage Account
    • Container name: catafract
    • Public access level: Blob (anonymous read access)
  2. 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:
Check the console for any missing environment variable errors. The application will log warnings for optional variables that are not set.

Security Best Practices

  • Never commit .env.local to version control
  • Add .env.local to .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