-
Notifications
You must be signed in to change notification settings - Fork 18
Environment Variables
As a developer who works with many environments, like local machine, your teammate's machine, staging, QA, or production, you need to make sure that changing app's config won't breaks other environments. The usual way is to have environment variables which varies between environments.
It's one of The Twelve-Factor App and I tried to adapt it as much as possible since some aren't applicable for client-side app.
The usual use cases:
- Staging server uses
stag-api.domain.com
where Production server usesapi.domain.com
- My local machine uses
localhost
where my teammate's machine usesapi.domain.dev
- PORT differences
The starter supports dotenv environment variables
It works by reading your .env
located at project root and send it to process.env
which Webpack will process
- Independently managed by each environment, resulting Scalable environment config (No file that groups every environments)
- No env is committed to source control
-
Create
.env
file or Copy one from.env.example
- Access the variable from
process.env.<YOUR_VAR>
on your node or app code
- Since this is client-side environment variables, DON'T STORE SENSITIVE INFORMATION like your api tokens, secret keys, or other variables that should be kept secret on server-side
- The whole Environment Variable is also optional, you can just ignore to create
.env
This starter may not fit for your workflow, since it's opinionated. Therefore you can always fork and custom it to fit your workflow
⭐ Support this starter by giving stars, sharing to your friends, or contributing