Trying to deploy PERN app in Heroku and getting 404s

Issue

I’m trying to get my app and server hosted on Heroku to work when deployed, but it’s not. Client and server seem appear to be running, but the api calls are returning 404s. I’m guessing the configs are messed up somewhere.

Here is my repo: https://github.com/kpermenter/test-deploy and my Heroku settings are attached.

Any insight would be much appreciated!heroku configs

Solution

This is because you haven’t made the client files available publicly, you can do this by using:
app.use(express.static(‘../client/build’));

in the server.js file
if this doesn’t work you can try creating a ‘public’ folder inside the server folder then copy the contents of the build inside the server/public folder and then use app.use(express.static('/public'));
and just deploy the server folder itself

Answered By – yagyesh

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published