Reputation: 702
I am using node foreman to load in some environment variables such as my DB string and some Gmail credentials to send an email.
My variables are correctly loading in on my local, but I can't get them to load in when deployed to Heroku.
package.json
{
"name": "mysite",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"body-parser": "*",
"express": "*",
"foreman": "1.4.1",
"method-override": "*",
"mongoose": "*",
"nodemailer": "*"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nf start"
},
"engines": {
"node": "*"
},
"author": "",
"license": "ISC"
}
.env
DB_URL='dbstring'
EMAIL_SERVICE='Gmail'
EMAIL_USERNAME='[email protected]'
EMAIL_PASSWORDTOKEN='pwtoken'
Procfile
web: node server.js
The node-foreman documentation says to .gitignore it, does this need to be undone if deploying to heroku? Neither node-foreman nor Heroku say that has to happen, so I am thinking not. But I am out of ideas.
Snapshot of env object logged out on production
env
{ WEB_MEMORY: '512',
PATH: '/app/.heroku/node/bin:/usr/local/bin:/usr/bin:/bin:/app/bin:/app/node_modules/.bin',
WEB_CONCURRENCY: '1',
PWD: '/app',
NODE_ENV: 'production',
PS1: '\\[\\033[01;34m\\]\\w\\[\\033[00m\\] \\[\\033[01;32m\\]$ \\[\\033[00m\\]',
SHLVL: '1',
HOME: '/app',
NODE_HOME: '/app/.heroku/node',
PORT: '34225',
_: '/app/.heroku/node/bin/node' }
Link to Heroku's documentation regarding Node-Foreman
Upvotes: 0
Views: 653
Reputation: 702
For anyone that is reading this in the future, I had an "ah-ha" moment when I realized Heroku has its own set of Environment Variables you set through the cmd/dashboard that Foreman will utilize.
Upvotes: 4