Setting Environment Variables
Local Development
Create a.env file in your project root:
Docker Deployment
Set variables indocker-compose.yml:
Production Servers
Set variables in your hosting environment (Heroku, AWS, etc.) or use a process manager like PM2.Database Configuration
PostgreSQL database hostDefault:
localhostExample: database (Docker), db.example.com (remote)PostgreSQL database portDefault:
5432Database name for EverShopDefault:
evershopDatabase usernameDefault:
postgresDatabase password
SSL mode for database connectionOptions:
disable- No SSL connectionrequire- SSL requiredprefer- Prefer SSL if availableverify-ca- Verify certificate authorityverify-full- Full SSL verificationno-verify- SSL without verification
disablePath to SSL root certificate fileRequired when using
verify-ca or verify-full SSL modes.Example: /path/to/ca-cert.pemPath to SSL client certificate fileExample:
/path/to/client-cert.pemPath to SSL client key fileExample:
/path/to/client-key.pemServer Configuration
HTTP server portDefault:
3000Example: 8080, 80Node.js environment modeOptions:
development- Development mode with hot reloadproduction- Production mode with optimizationstest- Testing mode
developmentJWT Authentication
EverShop uses JWT tokens for authentication with separate configurations for admin and customer sessions.JWT token issuer identifierDefault:
evershopAdmin JWT Configuration
Secret key for admin access tokensExample:
your-secret-admin-key-min-32-charsSecret key for admin refresh tokensShould be different from
JWT_ADMIN_SECRET.Example: your-refresh-admin-key-min-32-charsAdmin access token expiration time in secondsDefault:
900 (15 minutes)Admin refresh token expiration time in secondsDefault:
54000 (15 hours)Customer JWT Configuration
Secret key for customer access tokensExample:
your-secret-customer-key-min-32-charsSecret key for customer refresh tokensShould be different from
JWT_CUSTOMER_SECRET.Example: your-refresh-customer-key-min-32-charsCustomer access token expiration time in secondsDefault:
1800 (30 minutes)Customer refresh token expiration time in secondsDefault:
108000 (30 hours)Installation Variables
These variables are used during thenpm run setup installation process:
Full name of the initial admin userExample:
John DoePassword for the initial admin userMust meet requirements:
- At least 8 characters
- Contains at least one letter
- Contains at least one digit
123456 (change this!)Internal Variables
Allow configuration changes at runtimeDefault:
false (after startup)Example Configurations
Development Environment
Production Environment
Docker Compose
Security Best Practices
Use Strong Secrets
Generate JWT secrets using a cryptographically secure random generator:
Never Commit Secrets
Add
.env to your .gitignore file:Use Environment-Specific Values
Use different secrets for development, staging, and production environments.
Rotate Secrets Regularly
Change JWT secrets and database passwords periodically, especially after team member changes.
Troubleshooting
JWT Secrets Not Set
If you see errors about missing JWT secrets:JWT_ADMIN_SECRETJWT_ADMIN_REFRESH_SECRETJWT_CUSTOMER_SECRETJWT_CUSTOMER_REFRESH_SECRET
Database Connection Fails
- Verify all database credentials are correct
- Check that the database server is running
- Ensure the database user has proper permissions
- Verify SSL mode matches your database configuration
Port Already in Use
Change thePORT variable to use a different port: