-
Notifications
You must be signed in to change notification settings - Fork 72
03. Environment Variables
Certain configurations in our application will change depending on what "environment" in which the application is running. For example, our database in our development environment (aka on your machine) will be located at http://localhost:5432
; however, when deployed to production (e.g. on heroku), your database will likely be located in some service like the postgres addon for heroku.
You will also want to ensure that sensitive information like third-party application secrets and session encryption secrets for production do not enter a repository and live only in that production environment.
The server/env directory houses files that denote what values exist in which environments. In server/env/development.js, all values are hardcoded for use in development. However, in server/env/production.js, all values are accessed via the process.env
object. We will explore this environment file more in the pages that concern deployment to Heroku.
The application uses this environment configuration in many places, including database connection, session middleware and authentication strategies. Reference these files for examples: server/db/index.js, server/app/configure/authentication/index.js and others.