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

Hi there,

I am making a node.js express application (express-generator in case that helps) that is deployed to Heroku. I am using an AWS atlas cluster, and I am pretty knew to this. I am using mongoose in my express app. 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? I am simply doing a login, register, profile information functionality that stores in atlas.

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?

I don’t really do anything like a development or production environment, I simply write the code, run it on my localhost, then it is deployed automatically to Heroku with a ci on every commit and push.

If this helps, my project structure and functionality is extremely similar to https://www.youtube.com/watch?v=Us-JwsZtAwA&t=1193s this video. Thanks!

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

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.