Reputation: 599
I have deployed a react app to Netlify and if I navigate via the navbar I can access everything and it all works fine. If I however type something like https://example.com/contact
I get a not found error. I am using react-router-dom for navigation. Is there something I have to do on the Netlify side or React to fix this?
page not found - Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
Upvotes: 2
Views: 1267
Reputation: 319
Its because your react app is a SPA (Single page application) so you just have a one HTML document so when you type /contact will not find your HTML called "contact" so you need to redirect your app to your HTML page, here is a tutorial that you can follow up
link: https://www.freecodecamp.org/news/how-to-deploy-react-router-based-app-to-netlify/
Upvotes: 3
Reputation: 587
To fix this issue create a rewrite rule in the build folder.
Upvotes: 0