Home → The Classics → Farai's Codelab
Don’t Forget To Specify a 404 Page For Your Cloudflare Pages Site!
Published: Updated:
I was removing an old attempt at making linkstats and I was testing the redirect support (which I’ve removed for now) and entered in the wrong URL. Instead of returning some sort of 404, it stayed on the same page (well /
it turns out). Turns out this is by design. As per Cloudflare’s documentation on serving pages,
If your project does not include a top-level 404.html file, Pages assumes that you are deploying a single-page application… Pages’ default single-page application behavior matches all incoming paths to the root (
/
), allowing you to capture URLs like/about
or/help
and respond to them from within your SPA.
Don’t know why SPAs do that but its why Cloudflare does it. To address this, I just yanked a random 404 page I had lying around and I used that.