This document explains how to set up configuration for the Portal2 application.
-
Copy the configuration template and customize:
cp portal2.template.json portal2.json # Edit portal2.json with your configuration values -
Fill in required values (see Required Configuration below)
-
Start the application:
npm run dev
The application uses JSON configuration files:
portal2.json- Primary configuration file (NOT committed to git)portal2.template.json- Template with example values- Set
CONFIG_PATHenvironment variable to specify a custom config file location
These settings must be configured in your portal2.json file for the application to start:
{
"db": {
"user": "your_db_username",
"password": "your_db_password"
}
}{
"session": {
"secret": "your_very_long_secure_session_secret_here"
}
}{
"keycloak": {
"realm": "your_realm",
"authUrl": "https://your-keycloak.org/auth/",
"client": "your_client_id",
"secret": "your_client_secret"
}
}{
"ui": {
"baseUrl": "http://localhost:3000"
}
}You can specify a custom configuration file location:
# Use custom config file location
CONFIG_PATH=/path/to/custom/portal2.jsonAll configuration is stored in JSON format in the portal2.json file. See portal2.template.json for the complete structure and default values.
server.port- Main application port (default: 3000)- Environment: Set
NODE_ENV=productionfor production deployment
ui.baseUrl- Frontend base URL (required)ui.wsBaseUrl- WebSocket base URL
db.host- PostgreSQL hostdb.port- PostgreSQL port (default: 5432)db.name- Database namedb.user- Database usernamedb.password- Database passworddb.sessionTable- Session table name (default: "session")db.logging- Enable query logging (optional, default: false)
session.secret- Session signing secretsession.ttl- Session timeout in seconds (default: 86400)session.secureCookie- Use secure cookies (true for HTTPS)keycloak.*- Keycloak configuration (realm, authUrl, client, secret)security.hmacKey- HMAC key for token generationhoneypot.divisor- Anti-spam honeypot divisor (default: 7)
terrain.url- DE Terrain API URLterrain.user- Terrain service account usernameterrain.password- Terrain service account passwordportalConductor.url- User/service workflow conductor
smtp.*- SMTP server settingsbcc.*- BCC recipients for different email typessupport.email- Support email address
intercom.*- Intercom chat widget configurationexternal.googleAnalyticsId- GA tracking IDsentry.dsn- Error tracking
profile.updatePeriod- Days between required profile updatesprofile.warningPeriod- Days before showing update warningprofile.*Text- User-facing messages
# Copy and customize the configuration template
cp portal2.template.json portal2.json
# Edit portal2.json with your local settings:
# - Local database credentials
# - Development Keycloak settings
# - Disable external services
# - Set appropriate base URLs# Copy and customize the configuration template
cp portal2.template.json portal2.json
# Edit portal2.json with production values:
# - Production database and URLs
# - Real Keycloak configuration
# - Strong session secrets
# - External service credentials# Use environment-specific compose files
docker-compose -f docker-compose.yml -f docker-compose.local.yml up- Never commit
portal2.json- It's in.gitignore - Use strong, random values for
session.secretandsecurity.hmacKey - Rotate secrets regularly in production
- Use environment-specific secrets (different for dev/staging/prod)
- Set
session.secureCookie: truefor HTTPS - Use
NODE_ENV=production - Use real certificates and secure endpoints
Generate secure secrets with:
# Generate a session secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Or use openssl
openssl rand -hex 32The application validates configuration on startup and will:
- ✅ Show success message with loaded configuration
- ❌ Exit with clear error if required variables are missing
⚠️ Show warnings for optional missing variables- 🔍 Validate URL formats and data types
# Check if portal2.json exists
ls -la portal2.json
# Test configuration loading
node -e "const config = require('./src/api/lib/config'); config.init(); console.log('DB Host:', config.getDbConfig().host)"# Check startup logs for specific missing variables
npm run dev 2>&1 | grep "Missing required"// Ensure URLs are properly formatted with protocol
{
"ui": {
"baseUrl": "http://localhost:3000" // ✅ Good
}
}
// ❌ Missing protocol would be:
{
"ui": {
"baseUrl": "localhost:3000"
}
}portal2.json- Your configuration file (copy and customize from portal2.template.json, not committed to git)
After setting up your environment:
- Start the development server:
npm run dev - Check the startup logs for validation messages
- Visit
http://localhost:3000to test the application - Review the configuration guide for any optional features you want to enable