Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why React production build only shows the 404 page without the rest of the page?

I created a website with react and I’m using react-router-dom I want to deploy it to netlify, so i run npm run build but when I click the index.html. It only shows the route I created for the non-existing path i.e 404 page, How do I go about displaying the Homepage and the rest of the page?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Add a netlify.toml file to the root of your project and add the following lines. Then re-deploy on Netlify.

Redirects and rewrites

This is necessary to instruct netlify to redirect all routes to your app. So that react-router-dom can handle routing internally.

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading