Extra steps for a Node.js application using atlas deployed to Heroku?

HI @Cousin_Ale, welcome to the forums!

I was wondering, is there anything I should do so that me running on my localhost in development or people who visit my website at the heroku deployed can access and retrieve and send data with the site?

In Heroku you could configure environment variables. With this you could set an environment variable where your application could read the env variable value to determine which database cluster to connect to. For example, you could set an environment variable called ATLAS_URI which contains a MongoDB Connection String URI that points to your Atlas cluster.

I read a mongodb blog post about heroku with mongodb, but it did not really apply to me because they were not using mongoose but an npm lib called mongodb?

mongoose is an ODM library that utilises MongoDB Node JS driver (mongodb npm package) behind the scene. Which MongoDB + Heroku blog post are you referring to ?

If you still have a question about MongoDB and Heroku, it would be helpful if you could elaborate further on:

  • What you’re trying to achieve
  • What problem that you’re encountering i.e. error message
  • Example code, if relevant

Regards,
Wan.

1 Like