Relative Content

Tag Archive for reactjsdeploymentreact-routerxmlhttprequesthttp-status-code-404

Links returning 404 after deployment of React app on Render

I have a mock shop React application with a few different routes which works as expected on localhost. When deployed (both on Surge and Render) the subdirectories/links do not work.
My 404 page does not load too.
The funny bit is when I access a route from a link in the app it loads ok – for example a details page for an item. When I paste the very same url into a different tab or even refresh the current one, I get 404 again. I noticed that the actual http request in the second instance is not sent to my back end (vinyl-shop.onrender.com) but to the front end app (vinylarium.onrender.com):
The “good” request to my back end:

Links returning 404 after deployment of React app

I have a mock shop React application with a few different routes which works as expected on localhost. When deployed (both on Surge and Render) the subdirectories/links do not work.
My 404 page does not load too.
The funny bit is when I access an item details page from the link in the app it loads ok. When I paste the very same url into a different tab or even refresh the current one, I get 404 again. I noticed that the actual http request in the second instance is not sent to my back end (vinyl-shop.onrender.com) but to the front end app (vinylarium.onrender.com):
The “good” request to my back end: