Configure Environment Variables
Create a .env file in the project root.
Add the following development configuration:
PORT=3000
NODE_ENV=development
MONGODB_URI=mongodb://127.0.0.1:27017/rest_api_db
JWT_SECRET=replace-with-a-long-random-secret
JWT_EXPIRES_IN=15m
CLIENT_ORIGIN=http://localhost:5173
MONGODB_URI defines the database connection.
JWT_SECRET is used to sign and verify access tokens.
JWT_EXPIRES_IN controls token expiration.
CLIENT_ORIGIN defines the trusted frontend origin.
Create .env.example with the same variable names but safe example values.
Never commit the actual .env file.
Generate a cryptographically secure secret for JWT signing. The example value must be replaced before running authentication functionality.
node_modules/
.env
.env.*
!.env.example
coverage/
logs/
.DS_StorePrevents local environment files, dependencies, test coverage, and logs from being committed.
Environment variables keep configuration outside source code.
Never commit production secrets.
Keep an .env.example file to document required variables.