Skip to content Skip to sidebar Skip to footer

Express React App Works Locally But Gives Error On Heroku Deploy

i'm sure this has been solved, but i am unable to get this to work for me. locally my repo works with this as my /index.js const express = require('express'); const keys = requi

Solution 1:

I've deployed the following express configuration to Heroku to a create-react-app application:

app.use(express.static(path.join(__dirname, './client/public')))

app.get('*', function(_, res) {
  res.sendFile(path.join(__dirname, './client/public/index.html'), function(err) {
    if (err) {
      res.status(500).send(err)
    }
  })
})

You can see the full code here.

Post a Comment for "Express React App Works Locally But Gives Error On Heroku Deploy"