Hey Y’all. I feel like I’m so close, but I can’t seem to get it. I want my react app to be served on Heroku on my root route ‘/’, but I’m getting a not found
message as if the react build is not deployed. The server is working, but not the react app. Here is the server:
app.listen(process.env.PORT || 5000, function () {
console.log("Listening on port " + process.env.PORT);
});
if (process.env.NODE_ENV === 'production') {
// Serve any static files
app.use(express.static('client/build'));
// Handle React routing, return all requests to React app
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html'));
});
}
And here is the package.json scripts
"scripts": {
"heroku-postbuild": "cd client && npm install && npm run build",
"start": "node server.js",
"client": "cd client && npm start",
"dev": "concurrently --kill-others-on-fail \"yarn start\" \"yarn client\""
},
Thank you all for the help