Hi I uploaded my react app on server and make it live. It’s working fine but whenever I refresh any page of application. it’s returning 404 error. what should I do ?
Hi I uploaded my react app on server and make it live. It’s working fine but whenever I refresh any page of application. it’s returning 404 error. what should I do ?
2
Answers
When your app load. The react-router handle Router. The Route change is handled by Router itself but on refreshing the request goes to nginx where that specific route doesn’t exist.
To resolve this issue you need to load root file. try this solution.
in default file update location
there please add this in your nginx.conf
The problem is whenever you are trying to refresh the page it cannot find that route on nginx hence you get 404 whereas when you are browsing the app it just works fine because those things are handled by browser itself.