Step 13

Let's deploy the QuickNotes API to Heroku.

  1. Head over to Heroku and create a new app. I called mine quicknotes-api.

  2. In the Settings, Add "nodejs" as a "buildpack."

  3. Under "Deploy," select "GitHub" and connect the Heroku app to the GitHub repository of QuickNotes API. Make sure to enable automatic deployment.

  4. Add a Procfile to the project!

web: node ./server/index.js
  1. Remove the MongoDB cluster URL before pushing to the repository! We don't want to push our database URI to a public repository!!
- // TODO replace <password> with the password for quicknote-admin
- const URI = `mongodb+srv://quicknote-admin:<password>@quicknote.ydsfc.mongodb.net/quickNoteDB?retryWrites=true&w=majority`;

+ const URI = process.env.DB_URI;
  1. Add the URI as an environment variable to the Heroku app.

  1. Push the changes to the GitHub repository.

Make sure the Heroku app is successfully deployed and functions as expected.