What about “Setting Environment Variables on Heroku”? I still keep getting “application error”.
Sometimes, the config package that Mosh uses in his lecture does not work properly on heroku. Not sure why, but maybe due to the sandboxed nature of heroku slugs.
What you could instead do is, use
process.env command to access the environment variables on heroku.
So, if your database connection string is stored in an environment variable named “dbConn”, the command to retrieve it inside nodejs would be
Heroku automatically sets the node environment as “production”. You can access this using the command
As for how to set the environment variables on heroku, log on to Heroku, open your app, go to the settings tab, and click on Reveal Config Vars. You can then add any key-value pair as an environment variable that will be exposed to your app and accessible through process.env command.
For the other errors, it’s most likely a problem with the code. Please post a screenshot of your terminal/console showing the error and the commands you typed before that. It would help if you could also share a link to the github repo. That way I could help you debug better.