How to set environment variables on Heroku for Node app and connect to the PostgreSQL database?
According to documentation you could use heroku CLI
$ heroku config:set DATABASE_URI=database_uri_here$ heroku config:set SESSION_SECRET=session_secret... and so on for each variable,
or you could use UI https://dashboard-classic.heroku.com/apps/{your-app-name}/settings and provide same variables via web interface, as I mention in above comment
NODE_ENV=production
is not treated specially by heroku
, so you do need to provide it as well as any other env variable
ps: strictly speaking this question doesnt really belong in SO, as it's unrelated to programming. Maybe it need to be moved to SU
heroku config:set $(cat .env | sed '/^$/d; /#[[:print:]]*$/d')
set your config from .env file
Especially database connection variables will not work through Heroku env variables.I would suggest using dotenv and set variables to the file by installing Heroku CLI and then use bash:
heroku loginheroku run bash -a app_name
create .env
file if it is not there and add values to it
touch .envecho "ENV_VAR=value" >> .env
confirm the entry in a file
cat .env