This document lists all supported environment variables for the WorldGuessr project. Environment variables should be set in a .env.local file in the project root for local development, or configured in your deployment environment.
These variables are essential for the application to function properly:
# MongoDB connection string
MONGODB=mongodb://localhost:27017/worldguessr
# OR for MongoDB Atlas:
# MONGODB=mongodb+srv://username:password@cluster.mongodb.net/worldguessr
# Redis connection string for caching and sessions
REDIS_URI=redis://localhost:6379
# OR for Redis Cloud:
# REDIS_URI=redis://username:password@host:port
# Google OAuth Client ID (publicly visible)
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
# Google OAuth Client Secret (server-side only)
GOOGLE_CLIENT_SECRET=your_google_client_secret
# API server port (default: 3001)
API_PORT=3001
# WebSocket server port (default: 3002)
WS_PORT=3002
# Next.js development server runs on port 3000 by default
# Node.js environment mode
NODE_ENV=development
# OR
NODE_ENV=production
These variables are exposed to the browser and must be prefixed with NEXT_PUBLIC_:
# API server URL (publicly visible)
NEXT_PUBLIC_API_URL=localhost:3001
# OR for production:
# NEXT_PUBLIC_API_URL=api.yourwebite.com
# WebSocket server host (publicly visible)
NEXT_PUBLIC_WS_HOST=localhost:3002
# OR for production:
# NEXT_PUBLIC_WS_HOST=ws.yourwebsite.com
# Enable CoolMath Games mode
NEXT_PUBLIC_COOLMATH=true
# Enable Poki.com integration
NEXT_PUBLIC_POKI=true
# Maps.co API key for geocoding (if using)
NEXT_PUBLIC_MAPSCO=your_mapsco_api_key
# Discord webhook URL for main server notifications
DISCORD_WEBHOOK=https://discord.com/api/webhooks/your_webhook_url
# Discord webhook URL for WebSocket server notifications
DISCORD_WEBHOOK_WS=https://discord.com/api/webhooks/your_ws_webhook_url
# OpenAI API key for AI-generated clues (feature currently commented out)
# OPENAI_API_KEY=your_openai_api_key
# Secret key for enabling/disabling maintenance mode
MAINTENANCE_SECRET=your_secure_maintenance_secret
When deploying to CoolMath Games, set:
NEXT_PUBLIC_COOLMATH=true
This enables:
When deploying to Poki.com, set:
NEXT_PUBLIC_POKI=true
This enables:
CrazyGames integration is detected automatically via URL parameters (?crazygames=true), no environment variable needed.
# Database
MONGODB=mongodb://localhost:27017/worldguessr
REDIS_URI=redis://localhost:6379
# Google Auth
NEXT_PUBLIC_GOOGLE_CLIENT_ID=123456789-abcdefghijk.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your_client_secret
# Server Configuration
API_PORT=3001
WS_PORT=3002
NODE_ENV=development
# Client Configuration
NEXT_PUBLIC_API_URL=localhost:3001
NEXT_PUBLIC_WS_HOST=localhost:3002
# Optional: Discord notifications
DISCORD_WEBHOOK=https://discord.com/api/webhooks/your_webhook_url
DISCORD_WEBHOOK_WS=https://discord.com/api/webhooks/your_ws_webhook_url
# Optional: Maintenance mode
MAINTENANCE_SECRET=your_secure_secret
# Database (production URLs)
MONGODB=mongodb+srv://username:password@cluster.mongodb.net/worldguessr
REDIS_URI=redis://username:password@redis-host:port
# Google Auth (production credentials)
NEXT_PUBLIC_GOOGLE_CLIENT_ID=prod_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=prod_client_secret
# Server Configuration
API_PORT=3001
WS_PORT=3002
NODE_ENV=production
# Client Configuration (production URLs)
NEXT_PUBLIC_API_URL=api.worldguessr.com
NEXT_PUBLIC_WS_HOST=ws.worldguessr.com
# Discord notifications
DISCORD_WEBHOOK=https://discord.com/api/webhooks/prod_webhook
DISCORD_WEBHOOK_WS=https://discord.com/api/webhooks/prod_ws_webhook
# Maintenance mode
MAINTENANCE_SECRET=production_maintenance_secret
# All standard variables plus:
NEXT_PUBLIC_COOLMATH=true
# Note: Some features are automatically disabled in CoolMath mode:
# - Community maps
# - Chat functionality
# - User-generated content features
server.js)MONGODB - Database connectionAPI_PORT - Server portNODE_ENV - Environment modeDISCORD_WEBHOOK - Discord notificationsNEXT_PUBLIC_GOOGLE_CLIENT_ID - OAuth validationGOOGLE_CLIENT_SECRET - OAuth server-sidews/ws.js)MONGODB - Database connectionREDIS_URI - Session storageWS_PORT - WebSocket portNODE_ENV - Environment modeDISCORD_WEBHOOK_WS - WebSocket notificationsMAINTENANCE_SECRET - Maintenance mode controlclientConfig.js)NEXT_PUBLIC_API_URL - API endpointNEXT_PUBLIC_WS_HOST - WebSocket endpointapi/googleAuth.js)NEXT_PUBLIC_GOOGLE_CLIENT_ID - OAuth client IDGOOGLE_CLIENT_SECRET - OAuth validationcomponents/headContent.js)NEXT_PUBLIC_COOLMATH - CoolMath Games modeNEXT_PUBLIC_POKI - Poki.com integrationMONGODB connection stringNEXT_PUBLIC_GOOGLE_CLIENT_ID is setGOOGLE_CLIENT_SECRET is correctWS_PORT matches client expectationsNEXT_PUBLIC_WS_HOST is accessibleREDIS_URI is working for session storageThe application will log warnings for missing critical environment variables:
[MISSING-ENV WARN] MONGODB env variable not set[MISSING-ENV WARN] REDIS_URI env variable not set[MISSING-ENV WARN] NEXT_PUBLIC_GOOGLE_CLIENT_ID env variable not set[MISSING-ENV WARN] GOOGLE_CLIENT_SECRET env variable not setTo enable maintenance mode (requires MAINTENANCE_SECRET to be set):
# Enable maintenance mode
curl http://your-ws-server.com/setmaintenance/your_secret/true
# Disable maintenance mode
curl http://your-ws-server.com/setmaintenance/your_secret/false
For a minimal working setup, ensure these variables are set:
MONGODB - Database connectionREDIS_URI - Redis connectionNEXT_PUBLIC_GOOGLE_CLIENT_ID - Google OAuth clientGOOGLE_CLIENT_SECRET - Google OAuth secretNEXT_PUBLIC_API_URL - API server URLNEXT_PUBLIC_WS_HOST - WebSocket server URLOptional but recommended:
DISCORD_WEBHOOK - For monitoring and notificationsMAINTENANCE_SECRET - For emergency maintenance mode.env files to version controlMAINTENANCE_SECRETGOOGLE_CLIENT_SECRET is never exposed to clientsFor additional help with environment configuration, check the application startup logs for specific warnings about missing or misconfigured variables.