kim tech
kim tech

Reputation: 91

How do I avoid 404 error in deployed react app when I refresh page?

I'm trying to deploy react app on Netflify and it was okay before I deployed. However, since i deployed this app, whenever i refresh it didn't get the same URL,and it returns the 404 page on Netflify. so i tried to find it but i couldn't get how to do, and I deployed it only client side. I have no idea how to fix it without server side. So How do i avoid this issue??

And I searched to fix but it didn't work for some reason.

This is what i tried : enter image description here I added netlify.toml file in src folder and

[[redirects]]
  from = "/*"
  to = "/"
  status = 200

I wrote this in the file.

Thank you in advance !

Upvotes: 0

Views: 1103

Answers (1)

Ryan Le
Ryan Le

Reputation: 8412

Another method you could possibly try is to add a _redirects file inside your /public folder.

And then parse this into that file:

/*  /index.html  200

Deploy your app, and netify will check for that file, with any URL it returns to index.html with code 200

Detail explaination here.

Upvotes: 1

Related Questions