Hi all,
I have had this issue for a couple of weeks now and I have run out of ideas on what to try.
I have built a website using create-react-app for a friend. I have used react router for the links through out the website.
When I put the website live on a server, I'm not able to type the URL in the browser. If I do so, I get a Not Found error. It also happens if I'm on page on the website and I refresh it.
I have been told I need to add backend with nodejs and more specifically Express backend to the project so I can direct the pages to the index.html which I did but I still can't get it to work.
Any suggestions?
Thanks
Discussion
Is it deployed on Netlify ? If yes, you need to add a
_redirects
file in your public folder like so :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
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.
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.
How to deploy React Application on IIS Server
sumitkharche γ» Dec 8 γ» 3 min read
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).
Hi, I think that you should consult with the official create-react-app docs - create-react-app.dev/docs/deployment
Add
"homepage": "http://mywebsite.com or IP/"
in package.jsonMor info Here