I have a website which is hosted on Cloudflare pages. This is a simple static website (built with hugo).
I noticed that when I try and load a non-existent page (for example:
BASE_DOMAIN/non_existent), I get back a 200 OK from http and the root website is being loaded.
I think this is a behavior defined by Cloudflare because when I run the hugo server locally I do get a 404.
I wonder if this is a bug or a feature, and also what’s considered ‘best-practice’ to have. How do I turn off that behavior?
If your project does not include a top-level
404.html file, Pages assumes that you are deploying a single-page application. This includes frameworks like React, Vue, and Angular. Pages’ default single-page application behavior matches all incoming paths to the root (
/), allowing you to capture URLs like
/help and respond to them from within your SPA.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.