Environment Variables
All environment variables used by Dirework
All environment variables are defined in apps/web/.env. The app validates them at startup using t3-env.
Required Variables
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string |
BETTER_AUTH_SECRET | Secret key for Better Auth session encryption (min 32 characters) |
BETTER_AUTH_URL | Full URL of the web app (e.g. http://localhost:3001) |
CORS_ORIGIN | Allowed CORS origin, typically the same as BETTER_AUTH_URL |
TWITCH_CLIENT_ID | Twitch application client ID from dev.twitch.tv |
TWITCH_CLIENT_SECRET | Twitch application client secret |
Optional Variables
| Variable | Default | Description |
|---|---|---|
ALLOWED_TWITCH_IDS | "" (allow all) | Comma-separated list of Twitch user IDs allowed to sign in. Leave empty to allow any Twitch user. |
PRIVACY_POLICY_URL | (unset) | URL to your Privacy Policy page. When set, a link appears in the app footer. |
TERMS_OF_SERVICE_URL | (unset) | URL to your Terms of Service page. When set, a link appears in the app footer. |
NODE_ENV | "development" | Set to "production" for production deployments |
Example .env
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/dirework"
# Better Auth
BETTER_AUTH_SECRET="<your-secret-here>"
BETTER_AUTH_URL="http://localhost:3001"
CORS_ORIGIN="http://localhost:3001"
# Twitch OAuth (from dev.twitch.tv)
TWITCH_CLIENT_ID="your_client_id_here"
TWITCH_CLIENT_SECRET="your_client_secret_here"
# User allowlist (comma-separated Twitch user IDs, empty = allow all)
ALLOWED_TWITCH_IDS=""
# Legal page URLs (set to show links in footer, leave empty to hide)
# PRIVACY_POLICY_URL="https://example.com/privacy"
# TERMS_OF_SERVICE_URL="https://example.com/terms"Production Notes
For production deployments:
- Generate a strong
BETTER_AUTH_SECRETwithopenssl rand -base64 32 - Set
BETTER_AUTH_URLandCORS_ORIGINto your public domain (e.g.https://dirework.example.com) - Use a production PostgreSQL instance instead of the Docker development database
- Update the Twitch OAuth redirect URLs to match your production domain (see Twitch OAuth Setup)