Skip to content

Appendix: Environment Variables

This is a quick-reference for the 20 most important .env variables in Tina4 Node.js. For the complete reference of all 82 variables, see Book 0: Understanding Tina4, Chapter 4.


Top 20 Variables

VariableDefaultDescription
HOST0.0.0.0Bind address. 0.0.0.0 listens on all interfaces, 127.0.0.1 restricts to localhost.
PORT7148HTTP server port.
TINA4_DEBUGfalseMaster debug toggle. Enables stack traces, Swagger UI, live reload, query logging. Never true in production.
SECRETtina4-default-secretSecret key for JWT signing. Long, random, never committed to git.
DATABASE_URLsqlite:///data/app.dbConnection string. The URL scheme selects the driver.
TINA4_AUTOCOMMITfalseAuto-commit after every write. Default is off -- use explicit commit().
TINA4_CSRFtrueCSRF token validation on POST/PUT/PATCH/DELETE.
TINA4_CORS_ORIGINS*Comma-separated allowed origins. In production, list your actual domains.
TINA4_HSTS(empty/off)Strict-Transport-Security max-age in seconds. Set to 31536000 in production with HTTPS.
TINA4_CSPdefault-src 'self'Content-Security-Policy header.
TINA4_RATE_LIMIT100Maximum requests per window per IP.
TINA4_RATE_WINDOW60Rate limit window in seconds.
TINA4_SESSION_BACKENDfileSession storage. Options: file, redis, valkey, mongo, database.
TINA4_SESSION_TTL3600Session expiry in seconds.
TINA4_SESSION_SAMESITELaxSameSite cookie attribute. Options: Strict, Lax, None.
TINA4_WS_BACKPLANE(none)WebSocket backplane type. Set to redis for multi-instance broadcasts.
TINA4_WS_BACKPLANE_URLredis://localhost:6379Connection URL for the WebSocket backplane.
TINA4_LOG_LEVELERRORMinimum log level. Options: ALL, DEBUG, INFO, WARNING, ERROR.
TINA4_TOKEN_LIMIT60JWT token lifetime in minutes.
SMTP_HOST(none)SMTP server hostname.
SMTP_PORT587SMTP server port.
SMTP_USERNAME(none)SMTP authentication username.
SMTP_PASSWORD(none)SMTP authentication password.

Minimal .env for Development

dotenv
TINA4_DEBUG=true

That is it. Every other variable has a sensible default. Debug mode enables the Swagger UI, detailed error pages, and live reload. Start building.


Minimal .env for Production

dotenv
SECRET=your-long-random-secret-here
DATABASE_URL=postgresql://user:password@db-host:5432/myapp
TINA4_CORS_ORIGINS=https://myapp.com,https://www.myapp.com
TINA4_HSTS=31536000
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USERNAME=noreply@myapp.com
SMTP_PASSWORD=your-smtp-password

No TINA4_DEBUG. It defaults to false, which is what you want in production. The five things you must set: a real secret, a real database, locked-down CORS origins, HSTS enabled, and SMTP credentials if your app sends email.