Overview
POS Kasir uses environment variables for configuration. This page documents all available variables with their purpose, valid values, and recommendations.All configuration is read from
.env files in the root directory for the backend and web/.env for the frontend.Configuration File
Create your configuration by copying the example:.env with your specific values before running the application.
Server & Application Config
Core application settings that control runtime behavior.Application environment mode.Valid values:
development- Development mode with debug featuresproduction- Production mode with optimizations
Application name used in logs and responses.Example:
Port number for the backend server to listen on.Example:
When using Docker, this must match the internal port in
docker-compose.yml.Domain for setting cookies. Leave empty for localhost.Example:
Enable CORS for frontend requests.Valid values:
true- Allow cross-origin requestsfalse- Restrict to same origin
Database Configuration
PostgreSQL database connection settings.PostgreSQL database host address.Example:
PostgreSQL database port.Example:
Database username for authentication.Example:
Database password for authentication.Example:
Name of the PostgreSQL database.Example:
SSL/TLS mode for database connections.Valid values:
disable- No SSL (development only)require- Require SSL connectionverify-ca- Verify certificate authorityverify-full- Full certificate verification
Connection Pool Settings
Optimize database performance with connection pooling.Maximum number of open database connections.Recommendations:
- Development: 10
- Production (small): 25
- Production (large): 50-100
Maximum number of idle connections in the pool.Recommendations:
- Should be less than
DB_MAX_OPEN_CONNECTIONS - Typical value: 20-30% of max open connections
Maximum lifetime of a connection in minutes.Recommendations:
- Development: 10 minutes
- Production: 30-60 minutes
Migration Settings
Database schema migration configuration.Automatically run database migrations on startup.Valid values:
true- Auto-run migrations (convenient for development)false- Manual migration (recommended for production)
Path to database migration files.Example:
Logger Configuration
Application logging settings.Minimum log level to output.Valid values (in order of severity):
debug- Detailed debugging informationinfo- General informational messageswarn- Warning messageserror- Error messages only
Output logs in JSON format for log aggregation systems.Valid values:
true- JSON format (recommended for production)false- Human-readable format (better for development)
JWT Authentication
JSON Web Token configuration for user authentication.Secret key for signing JWT tokens.Requirements:Generate a secure secret:
- Minimum 32 characters
- Use random, cryptographically secure string
- Never reuse across environments
Token expiration time in hours.Recommendations:
- Web app: 24 hours
- Mobile app: 168 hours (7 days)
- API clients: 1 hour with refresh tokens
JWT issuer claim for token validation.Example:
Midtrans Payment Gateway
Configuration for Midtrans payment processing integration.Midtrans server key for API authentication.Where to find:
- Login to Midtrans Dashboard
- Go to Settings > Access Keys
- Copy Server Key (Sandbox or Production)
Use Midtrans production environment.Valid values:
true- Production mode (real transactions)false- Sandbox mode (testing)
Always test thoroughly in sandbox mode before enabling production.
Cloudflare R2 Storage
Cloudflare R2 object storage configuration for file uploads.Cloudflare account ID.Where to find:
- Login to Cloudflare Dashboard
- Go to R2 > Overview
- Copy Account ID
R2 API access key ID.Where to find:
- Cloudflare Dashboard > R2
- Manage R2 API Tokens
- Create API token or use existing
- Copy Access Key ID
R2 API secret access key.Where to find:
- Shown only once when creating API token
- Cannot be retrieved later - must regenerate if lost
R2 bucket name for storing files.Example:
Use separate buckets for different environments to prevent data mixing.
Public domain for accessing R2 files.Setup:
- Create R2 bucket
- Enable public access or custom domain
- Configure DNS (if using custom domain)
Pre-signed URL expiration time in seconds.Recommendations:
- Public files: 3600 (1 hour)
- Private files: 900 (15 minutes)
- Temporary uploads: 300 (5 minutes)
Environment-Specific Examples
Development Environment
Production Environment
Security Best Practices
1. Never Commit Secrets
Add.env to .gitignore:
2. Use Strong Random Values
Generate secure secrets:3. Environment Separation
Use different values for each environment:- Development:
.env.development - Staging:
.env.staging - Production:
.env.production
4. Secrets Management
In production, use secrets management services:- AWS: AWS Secrets Manager
- Google Cloud: Secret Manager
- Azure: Key Vault
- HashiCorp: Vault
- Docker: Docker Secrets
- Kubernetes: Kubernetes Secrets
5. Access Control
Restrict file permissions:6. Audit Regularly
- Review access to secrets monthly
- Rotate credentials quarterly
- Monitor for unauthorized access
- Use different credentials per environment
Validation
Validate your configuration before deployment:Troubleshooting
Variable Not Loading
Docker Not Reading .env
Database Connection Fails
Next Steps
Docker Deployment
Deploy using Docker Compose
Production Guide
Production deployment best practices