wk 4 Deploying - Sophievanderburg/blok-tech GitHub Wiki

🌐 Deployment

About Heroku

"Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. Our platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.

Heroku is fully managed, giving developers the freedom to focus on their core product without the distraction of maintaining servers, hardware, or infrastructure. The Heroku experience provides services, tools, workflows, and polyglot support—all designed to enhance developer productivity."
-Heroku

My deploying experience

When you deploy for the first time with Heroku, it might be a bit of work. I think the steps on the Heroku website are not as clear as they can be. There is one main "roadmap" of how to use it, but when you want to do things a certain way you need to go to another page. Which is, in my opinion, not very convenient. Maybe Heroku should consider rebuilding those flows and make the user choose in the beginning which path they want to follow. Eventually I made it work, with help some of a friend and Google (Google is my best friend when it comes to developing).

Problems I encountered

When I was trying to deploy my application, I encountered a view problems. I'd like to share them with you so that you don't have to get as frustrated as I was.

  1. If you use a MongoDB Atlas database, you need to set your IP adress to "0.0.0.0/0". You can do this at Network Acces which stands in the sidebar of the Atlas overview.
  2. You have to put your env-variables in Heroku so it can use them to make a database connection. You can do this by going to you app settings and add them to the Config Vars.
  3. Heroku wants to choose a port itself. So you need to set your port to const port = process.env.PORT || 3000; (do not add PORT to your env-file). If you have this code in your server.js, Heroku can choose a port itself. When you run the application locally, it uses port 3000.
  4. Make sure you have a procfile in the root of you application. Click here to read why.
  5. If something goes wrong with deploying you can find the ERRORS in the application logs. You can find those under the "more" button in the top right corner of your screen and then click "view logs". If you do not know what the error means, Google it! Most times you are not the first person to encounter that problem.