DEV Community

Discussion on: React Router not Working in Production

Collapse
 
karnak19 profile image
Basile

Is it deployed on Netlify ? If yes, you need to add a _redirects file in your public folder like so :

/* /index.html 200
Collapse
 
brianemilius profile image
Brian Emilius

This is an issue no matter what platform you deploy to.
Netlify made it easy, but depending on what platform you use, you need to checkout their documentation on how to redirect all requests to /index.html

Collapse
 
johnziss9 profile image
John

Not on Netlify unfortunately. I just run npm run build, got the files and uploaded them on a web host server my friend has purchased.

Collapse
 
dance2die profile image
Sung M. Kim

This is not the problem with RR per se, more of a server-side issue for SPAs.

e.g.) The same error occurs on IIS as well.

You might wan to consult with the host server, to find out the site server, and how to configure it work. (apache, nginx, they all have a way to redirect).