.env.example to .env and fill in the values before starting the server.
.env.example
.env.example
Variable reference
| Variable | Default | Required | Description |
|---|---|---|---|
PORT | 3000 | No | Port the HTTP server listens on |
NODE_ENV | development | No | Runtime environment (development or production) |
DB_HOST | localhost | Yes | PostgreSQL host |
DB_PORT | 5432 | Yes | PostgreSQL port |
DB_NAME | mais-habito-db | Yes | Database name |
DB_USER | postgres | Yes | Database user |
DB_PASSWORD | (empty) | Yes | Database password |
JWT_SECRET | change-this-secret | Yes | Secret key used to sign JWT tokens |
FRONTEND_URL | — | Yes | Allowed CORS origin for the frontend app |
Variable details
Port the Express server binds to. Override this when running multiple services
on the same host or deploying behind a reverse proxy.
Controls runtime behavior: logging verbosity,
.env file loading, SSL
enforcement, and migration file extension. Accepted values are
development and production.Hostname or IP address of the PostgreSQL server.
TCP port PostgreSQL is listening on.
Name of the PostgreSQL database. The
.env.example uses mais_habito;
make sure the value matches the database you created.PostgreSQL role used to connect to the database.
Password for the PostgreSQL role specified in
DB_USER.Secret string used to sign and verify JWT access tokens. Must be kept
private — never commit it to version control.
Full origin URL of the frontend application (e.g.
http://localhost:5173).
This value is passed directly to the CORS middleware as the allowed origin.When
NODE_ENV is set to development, the API automatically loads
variables from a .env file at the project root via dotenv. In
production, environment variables must be injected by the host environment
(e.g. Docker, Railway, or a process manager) — the .env file is not read.
SSL for the database connection is also enabled automatically in production.