Overview
WhatDoc uses environment variables for all runtime configuration. Variables are split between the server (Express backend) and client (Vite frontend).[!WARNING] Never commit.envfiles to version control. Always use.env.exampleas a template and keep actual secrets secure.
Server Environment Variables
Createserver/.env:
Core Configuration
MONGO_URI
Required | string
MongoDB connection string.
[!TIP]
For production, use MongoDB Atlas with connection pooling enabled. Include maxPoolSize=50 in the connection string for better performance.
JWT_SECRET
Required | string | Min 32 characters
Secret key for signing JSON Web Tokens used in authentication.
[!WARNING] Using a weak JWT secret compromises all user sessions. Use a cryptographically secure random string.
PORT
Optional | number | Default: 3000
Port the Express server listens on.
AI/LLM Configuration
GEMINI_API_KEYS
Required | string (comma-separated)
One or more Google Gemini API keys. Multiple keys enable round-robin rotation to avoid rate limits.
- Must be 39+ characters
- Must start with
AIzaSy - Invalid keys are automatically filtered out on startup
[!NOTE] The free tier has rate limits (~15 requests/minute per key). Use 3-5 keys for smooth operation with multiple users.
GEMINI_API_KEY
Deprecated | string
Old single-key configuration. Still supported but GEMINI_API_KEYS is preferred.
CORS & Domain Configuration
CLIENT_URL
Required | string
Frontend URL for CORS and OAuth redirects.
CORS_ORIGINS
Required | string (comma-separated)
Allowed origins for CORS. Automatically includes CLIENT_URL if not listed.
[!TIP]
WhatDoc automatically allows subdomains matching APP_DOMAIN and custom domains registered in the database.
APP_DOMAIN
Required | string
Base domain for subdomain routing (e.g., project.whatdoc.xyz).
GitHub OAuth
GITHUB_CLIENT_ID
Required for GitHub auth | string
GitHub OAuth application client ID.
GITHUB_CLIENT_SECRET
Required for GitHub auth | string
GitHub OAuth application client secret.
GITHUB_CALLBACK_URL
Required for GitHub auth | string
OAuth callback URL registered with GitHub.
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL to match
GITHUB_CALLBACK_URL - Copy Client ID and generate a Client Secret
Payment Gateway (Optional)
RAZORPAY_KEY_ID
Optional | string
Razorpay API key ID for payment processing.
RAZORPAY_KEY_SECRET
Optional | string
Razorpay API key secret.
[!NOTE] If not provided, defaults toTEST_KEYandTEST_SECRETfor development.
Promo Codes & Feature Flags
PRO_CODE
Optional | string
Promo code to unlock Pro features.
FREE5DOCS_CODE
Optional | string | Default: FREE5DOCS
Promo code to unlock 5 free documents.
PROMO_10GEN_CODE
Optional | string | Default: WHATDOCFAM
Promo code for 10 free generations.
PROMO_10GEN_LIMIT
Optional | number | Default: 100
Maximum number of uses for the 10-generation promo code.
Redis Queue (Optional)
REDIS_URL
Optional | string
Redis connection string for BullMQ job queue. Enables background processing.
[!TIP] Redis is optional but recommended for production. Without it, documentation generation blocks the main thread.
Cloudflare Integration (Optional)
CLOUDFLARE_ZONE_ID
Optional | string
Cloudflare zone ID for DNS management.
CLOUDFLARE_API_TOKEN
Optional | string
Cloudflare API token with DNS edit permissions.
Vercel Integration (Optional)
VERCEL_PROJECT_ID
Optional | string
Vercel project ID for custom domain management.
VERCEL_API_TOKEN
Optional | string
Vercel API token for domain API access.
Client Environment Variables
Createclient/.env:
Core Configuration
VITE_API_URL
Required | string
Backend API base URL.
[!NOTE]
Vite environment variables must be prefixed with VITE_ to be exposed to the client.
VITE_APP_DOMAIN
Required | string
Domain for subdomain resolution.
Firebase (Optional)
Used for analytics or additional auth methods.VITE_FIREBASE_API_KEY
Optional | string
VITE_FIREBASE_AUTH_DOMAIN
Optional | string
VITE_FIREBASE_PROJECT_ID
Optional | string
VITE_FIREBASE_STORAGE_BUCKET
Optional | string
VITE_FIREBASE_MESSAGING_SENDER_ID
Optional | string
VITE_FIREBASE_APP_ID
Optional | string
Cloudinary (Optional)
Used for avatar uploads in user profiles.VITE_CLOUDINARY_CLOUD_NAME
Optional | string
VITE_CLOUDINARY_UPLOAD_PRESET
Optional | string
Complete Example Configurations
Development Setup
server/.env:Production Setup
server/.env:Validation & Troubleshooting
Check Server Configuration
Verify Gemini API Keys
The server validates keys on startup:Common Issues
Server wonβt start:- Ensure
MONGO_URIis correct and MongoDB is running - Verify
JWT_SECRETis at least 32 characters - Check
GEMINI_API_KEYSformat (must start withAIzaSy)
- Add frontend URL to
CORS_ORIGINS - Verify
CLIENT_URLmatches actual frontend URL - Check
APP_DOMAINfor subdomain routing
- Ensure
GITHUB_CALLBACK_URLmatches GitHub app settings exactly - Verify
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETare correct - Check that callback URL is reachable from GitHub servers
- Add more API keys to
GEMINI_API_KEYSfor rotation - Consider upgrading to Gemini Pro for higher limits
- Enable Redis for queue-based processing
[!WARNING]
If you change JWT_SECRET in production, all existing user sessions will be invalidated and users will need to log in again.
