Environment Variables

Every variable ngXpress reads, and what to set in production.


Copy the example file to get started:

Terminal
cp .env.example .env

Reference

VariableRequiredDescription
DATABASE_URLYesPostgreSQL connection string Prisma uses. Default provider is postgresql.
BETTER_AUTH_SECRETYesSigning secret for sessions. Generate with openssl rand -base64 32.
BETTER_AUTH_URLYesThe public origin the app is served from — http://localhost:4200 in dev, your HTTPS domain in production.
BETTER_AUTH_TRUSTED_ORIGINSYesOrigins allowed to make authenticated requests. Must match BETTER_AUTH_URL exactly — no trailing-slash mismatches.
NODE_ENVProductionSet to production for a production build/run.
PORTNoPort the Node server listens on. Defaults to 4000 when unset.

Local development

.env (development)
DATABASE_URL="postgresql://USER:PASS@localhost:5432/ngxpress"
BETTER_AUTH_SECRET="dev_secret_generate_your_own"
BETTER_AUTH_URL="http://localhost:4200"
BETTER_AUTH_TRUSTED_ORIGINS="http://localhost:4200"

Production

.env (production)
DATABASE_URL="postgresql://USER:PASS@HOST:5432/ngxpress"
BETTER_AUTH_SECRET="your_secret_key"
BETTER_AUTH_URL="https://yourdomain.com"
BETTER_AUTH_TRUSTED_ORIGINS="https://yourdomain.com"
NODE_ENV="production"
PORT=4000

Trusted origins must match exactly

BETTER_AUTH_TRUSTED_ORIGINS is compared literally against the request origin. https://yourdomain.com and https://yourdomain.com/ are different strings to Better Auth — pick one and use it everywhere.

See Production Deployment for the full production checklist.