As the Title States I have a React + NodeJS + Express + MySQL that we are trying to deploy to a Heroku webpage. I have it set to auto deploy every time something is pushed to the master branch of GitHub.
The issue that we are running into is it is deploying the routes for the server and displaying all of the correct information but the react app isn't displaying at all. How can I make it so that the server routes aren't showing but the react frontend is?
Attached is the code for the Server.js as well as the script that I am running to build the client.
const express = require('express')
const cors = require('cors')
const app = express()
const path = require('path');
const port = process.env.PORT || 8080;
const homeRoute = require("./routes/home");
const allReviews = require("./routes/getAllReviews");
const mostRecentReviews = require("./routes/mostRecentReview");
const postReview = require("./routes/postReview");
const editReview = require("./routes/editReview");
const updateReview = require("./routes/updateReview");
const deleteReview = require("./routes/deleteReview");
const filterReview = require("./routes/getFilterReview");
const recentReviews = require("./routes/mostRecentReview");
const locationAverageRating = require("./routes/locationAverageRating");
const allLocations = require('./routes/allLocations');
app.use(cors())
app.use('/', homeRoute);
app.use('/review', allReviews);
app.use('/locations', allLocations);
app.use('/review/recent', mostRecentReviews);
app.use('/review/post', postReview);
app.use('/review/edit', editReview);
app.use('/review/update', updateReview);
app.use('/review/delete', deleteReview);
app.use('/review/filter', filterReview);
app.use('/carrier/recent',recentReviews);
app.use('/carrier/edit', editReview);
app.use('/carrier/locations', locationAverageRating);
app.use(express.static('client/build'));
app.get('*', (req, res) =>{
res.sendfile(path.resolve(__dirname + "./client/build/index.html"));
});
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`Example app listening on port ${port}!`)
});
Heroku build script:
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
Thank you in advance for the help and if you need any other files or have any questions feel free to reach out!