Home
Support Forums

Error 404 Page not Found

I deployed my app using Netlify, most pages work correctly. Sometimes when data is sent to my backend and the page is changing to a new url, the error 404 comes up instead. I have index.html in my root path. Everything works locally, even on refresh. Any suggestions?

Well it’s hard to guess this way. We’d need a link of the website or the link to the repository would be even better.

But in general, if the page exists before the URL is changed, it should not return 404.

Here is the link to the repository:

Which page is the one givie problem?

EDIT: After filling out the entire form on the first link with random information, in the end I got a button to Return home. Clicking on that took to me a 404 page. That’s probably because your home page is / and not /home. Have you tried it already? The problem is, after we get one 404 on your website, there’s no other to to come out of it except for retyping the URL in the address bar. It’s probably because you might be using React Router and thus, there’s no real index.html file at the new URLs that are being generated (including home).

I need my root page to be / because not all users will have a /home page. Should I use something other than React router?

In that case, you’d have to programatically add links to the ‘home page’. To avoid confusion, I’ll call the website’s root (/’) as home page and the ‘home’ of the users as the profile page. So, the users who are not going to have their dedicated profile page should be taken to website’s home.

Here’s an excellent guide to handle 404 when using React Router: https://stackoverflow.com/questions/27928372/react-router-urls-dont-work-when-refreshing-or-writing-manually

It’s a pretty common issue. Try and check if something works for your case. If nothing works, you’ll have to drop using React Router and maybe use something like Firebase to authenticate users. However, when doing that, your pages won’t be dynamically generated and they should already exist while deploying.