FilterLists
FilterLists copied to clipboard
404 non-existent routes
In new UI, routes like https://filterlists.com/404 do not exist and should return a proper 404 response and page or redirect to a valid page.
Seems like it's showing valid page when you enter invalid url. Or you want to do a redirect to 404 page?
yeah, for proper SEO, we should return an actual 404 page with a 404 HTTP response or redirect to the actual canonical route of the homepage. this needs to be fixed using React Router somehow. I'm not a React Router expert, and just haven't had the time to look into it.
I can either show NotFound component, or redirect to home page. Which would you prefer?
Some quick Googling seems to say to keep the 404 rather than redirect all 404s. So, let's try to return a 404 with a simple 404 not found page. Maybe the page can then have a clickable link back to the homepage.
Thanks, @smikis , we're part of the way there. We're still getting 200 OK statuses rather than 404, however. That might be an nginx config issue rather than something inside of the React app?

As far as I know doing it from react router is possible only with server side rendering enabled
It displays a 404 Not Found but does so still using html; i.e. it's still actually pointed to filterlists.com/xxxxx where xxxxx=non-existent directory. Check your cache settings in Cloudflare to make sure it's set to Standard. If not, that is likely the issue. If you'd prefer to continue serving 404's as you are currently, I suggest serving them as JSON responses to the requests so it's simple for networks to understand. One way you could accomplish would be to use a simple worker script via Cloudflare workers routed to all non-existent directories that will serve an application/json response instead of text/html. If it is a matter of simply changing Cloudflare's cache settings, there's technically no need for scripting on your side. You can, though, direct your current worker (assuming that's what modifying your http response headers) to follow all paths using two asterisks - one before & one after the route like so *filterlists.com*. That way you'll technically never leave filterlists.com but the server will still display a 404. Note that I only use GitLab & Cloudflare, though, since it's all I require; you've a far more complicated setup so I cannot be certain of anything functioning for you as it does for me.