React router route isn't working on reload

PLEASE help us help you by writing a good post!

  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot

The better the post - the faster the answer.
Site Name: https://projectshala.netlify.app

I have used react router for routing my pages and it’s working perfectly fine in my local deployment but the deployed site have errors.

Suppose I have entered https://projectshala.netlify.app in my URL then I will be successfully able to access my site.

But if my entry point is Projectshala - All you need for your Project then it gives 404 error whereas if I go to https://projectshala.netlify.app and then navigate to /about page from within the navigation bar then it’s working perfectly.

This is not the issue in my local deployment.

To all who will be seeing this error in future.

To fix this error on Netlify you can use Netlify’s redirect feature.

Just create _redirects file in your Public folder and paste this in _redirects - /* /index.html 200.

2 Likes

Hey there, @dev-elixir :wave:

Thanks for coming back and sharing your solution! It will definitely be beneficial to folks who encounter a similar obstacle in the future.

Happy building :rocket: