Reputation: 524
My app won't properly deploy or connect to my Mongo Atlas DB on Heroku. It keeps crashing. The heroku URL just says to do the logs, so here are the command line logs:
Here is what my server.js file looks like:
Here is what my config/keys looks like:
Here is what my keys_prod.js file looks like:
Here is what my keys_dev.js file looks like (redacted username and password), but this is what I have for my config vars in the heroku backend as well
Also took this screenshot, not sure if it matters though:
Upvotes: 2
Views: 3641
Reputation: 524
I didn't set the Heroku config vars correctly. I had set it to mongoURI like it was in the prod.keys JS folder instead of being MONGO_URI like I had declared it. In addition, I had to whitelist all of the ip's in Heroku's settings.
Upvotes: 1
Reputation: 2937
In deployment platforms like heroku, its hard to configure .env
. i solved this in my project by using a npm package dotenv. Whatever file need process.env
init,use this package
common require.js way :
require('dotenv').config()
its also got some cool options to manage env
here is the link
Upvotes: 0