Don't check in your API keys into your git repo, ever.
- If you've already checked in an API key for a service to your git repo, generate a new key
- Create a file called
.envin your project's root directory - Store your API keys in your
.envfiles in this format:API_KEY_NAME=api_key_value - Anywhere you had written your key in your js files, use the expression
process.env.API_KEY_NAMEto get the value of the API key from your environment - If you have multiple keys, each key-value pair should be on a new line - See Environment
- Add your
.envfile to.gitignoreso that you don't check in your.envfile into your git repo - Create a
Procfile_devfile and addweb: nodemon index.jsto it. - Start your app locally with
foremanby writingforeman start -f Procfile_dev - From now on your apps will start on port
5000so please go tohttp://localhost:5000in your browser to see your app. - Set your environment variables on heroku by writing the following command in your terminal:
heroku config:set API_KEY_NAME=api_key_value