Required Variables
These environment variables must be set for the application to start:Application URLs
Defines the trusted domains at which users can authenticate themselves. Must be a valid URL.Example:
https://your-domain.com or http://localhost:3000The base URL for the application. Must start with
http and include ://.Example: http://localhost:3000 or https://app.example.comAuthentication
Base64-encoded secret used for signing authentication tokens. Must be cryptographically secure.Generate a secret:Example:
dGhpc2lzYXNlY3VyZXJhbmRvbXN0cmluZw==Database Configuration
Database host URL, IP address, or Docker service name. Must not contain spaces when using a service name.Examples:
- Docker Compose:
dbormysql - External host:
192.168.1.100 - URL:
mysql.example.com
Database port number. Converted to integer internally.Default:
3306 (MySQL standard port)Name of the database to use.Example:
KnowledgeCheckrDatabase username for authentication.Example:
root or appuserDatabase password. Optional for development, but strongly recommended for production.Example:
secure_password_123Optional Variables
OAuth Providers
GitHub Authentication
GitHub OAuth application client ID. Both
AUTH_GITHUB_ID and AUTH_GITHUB_SECRET must be provided to enable GitHub authentication.How to obtain:- Go to GitHub Settings > Developer settings > OAuth Apps
- Create a new OAuth application
- Copy the Client ID
GitHub OAuth application client secret. Required if
AUTH_GITHUB_ID is set.Security: Never commit this value to version control.Google Authentication
Google OAuth 2.0 client ID. Both
AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET must be provided to enable Google authentication.How to obtain:- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Copy the Client ID
Google OAuth 2.0 client secret. Required if
AUTH_GOOGLE_ID is set.Security: Never commit this value to version control.Custom Authentication Provider (Dex)
URL, IP, or service name for the Dex OIDC provider. Required when
NEXT_PUBLIC_MODE is set to test.Examples:- Docker Compose:
dex - External:
https://dex.example.com - Development:
http://localhost:5556
Client ID for Dex authentication. Defaults to
nextjs-client.Client secret for Dex authentication. Defaults to
dev-secret.Production: Always override the default value.Application Behavior
Application mode. Determines which features are enabled.Options:
development, production, testNote: When set to test, Dex configuration becomes required.Whether to display the application version in the UI. Set to
true to enable.Example: true or falseLogging & Monitoring
Enable capture of client-side logs for debugging. Set to
true to enable.Example: trueEnable file-based logging using Winston. Set to
false to disable.Example: trueEnvironment File Examples
Minimal Configuration (Development)
Production Configuration
Test Environment with Dex
Validation Rules
The application enforces strict validation rules defined in~/workspace/source/src/lib/Shared/Env.ts:1-145:
OAuth Provider Validation
For each OAuth provider (GitHub, Google):- If both ID and secret are missing: Provider is disabled (no error)
- If only one is provided: Validation error - both must be set
- If both are provided: Provider is enabled
Test Mode Requirements
WhenNEXT_PUBLIC_MODE=test:
DEX_PROVIDER_URLis requiredDEX_CLIENT_IDis requiredDEX_CLIENT_SECRETis required
Type Conversions
Certain variables are automatically converted:DATABASE_PORT: String → IntegerSHOW_APP_VERSION: String → BooleanCAPTURE_CLIENT_LOGS: String → BooleanENABLE_FILE_LOGGING: String → Boolean
true, anything else → false
Validation at Runtime
Environment variables are validated at two points:- Build time: During
npm run build(optional) - Runtime: Before application starts (mandatory)
Docker-Specific Configuration
When using Docker Compose (~/workspace/source/docker-compose.yml:1-41):
Environment Variables in docker-compose.yml
Some variables can be set directly in the compose file:Using .env File
For sensitive data, use an.env file referenced in docker-compose.yml:
.env file override those in the environment section.
Service Name as Host
In Docker Compose, use the service name as the database host:Security Best Practices
- Generate secure secrets: Use cryptographic tools like
opensslto generate random secrets - Use environment-specific files: Maintain separate
.env.development,.env.production, etc. - Restrict file permissions: Set
.envfiles to read-only for the application user - Rotate credentials regularly: Change passwords and secrets periodically
- Use secret management: In production, consider using secret management tools (Vault, AWS Secrets Manager, etc.)
Troubleshooting
”Missing Environment Variables” error
The application will print the exact variables that are missing or invalid:.env file.
OAuth provider not appearing
Check the application logs on startup:Database connection failures
Verify your database configuration:- Ensure
DATABASE_HOSTis reachable from the application - Check that
DATABASE_PORTis correct (default: 3306) - Verify credentials are correct
- Confirm the database exists
Boolean values not working
Boolean environment variables must be strings:true.