How to deploy a MERN Stack App to Heroku

Hosting on Heroku – How to deploy a MERN Stack App to Heroku

How to deploy a MERN Stack App to Heroku

Hosting on Heroku

Building a MERN stack app is thing, deploying it can be a nightmare. In this video, we’re going to show you exactly step by step on how to deploy a MERN Stack App to Heroku

🔔 Don’t forget to subscribe 🔔

Interested in supporting this channel? Please use this link

📚Resources 📚:
Github Repo:

Other Related Videos :
✅ Set up the Reactjs and Nodejs structure:
✅ Run Reactjs and Nodejs in same terminal – Concurrently:
✅ Connect to MongoDB Atlas cluster with Mongoose:
✅ Robot 3t demo, models and routes refactor (code move in separate files):
✅ Create & submit a form in Reactjs and resolved cors policy:
✅ Save data to MongoDB with Mongoose:
✅ Get/fetch data from MongoDB and display them in Reactjs application:
✅ Apply css styles to a Reactjs application:
✅ How to deploya MERN stack App to Heroku:
✅ Connect MongoDB Atlas to your Heroku application:
✅ Enable automatic deployment to Heroku:

🤗Let’s connect 🤗:
👉 LinkedIn:

you search:

Hosting on Heroku

How to deploy a MERN Stack App to Heroku

21 thoughts on “Hosting on Heroku – How to deploy a MERN Stack App to Heroku

  1. Thank you so much. I tried so much hard to host mern app by hosting frontend on netlify and backend on Heroku. But unfortunately, I was blocked by cors. I tried StackOverflow but it was not also working. But I got you like a god and you saved my life. Thank you soooo ssooooo much.

  2. Question: I am also using express cors where I have hard coded that the request will come from localhost:3000 and in Reactjs I am using axios in that I have defined that the backend is running on localhost:3001 and if port is allocated dynamically how should I change that in react and express

  3. The mongolab:sandbox addon is no longer available. What you can do instead is connect directly to atlas without an addon. Just make sure to add the config vars (in the heroku dashboard go to personal > app > settings > config vars). The config vars are the MONGODB_URI and the NODE.ENV===production (the ones from the server.js file). The next tutorial in this playlist shows how it's done.

  4. Just got a doubt – The frontend fetches the API call from port 8080 , but our node server can run on any randomly assigned PORT by heroku. How do we know what port is assigned to our server by heroku?

  5. If anyone is having issues with a 404 error when running 'heroku local'…

    Make sure the following code snippet is ABOVE your routes in server.js-

    if (process.env.NODE_ENV === 'production') {

    //// PUT ROUTES HERE ////
    app.use('/api', routes);

    Hope this helped someone, thanks for the great video!

Leave a Reply

Your email address will not be published. Required fields are marked *