The Cloudflare 404 Trap and Single Page Applications
Cloudflare Pages makes assumptions about routing that can devastate SEO for sites that don’t configure 404 handling properly. Understanding this behavior prevents a common mistake that wastes crawler resources.
How Cloudflare Interprets Missing 404 Pages
When you deploy to Cloudflare Pages without a 404.html file in the root directory, Cloudflare assumes you’re running a single page application. In SPA mode, all requests for non-existent paths redirect to the root path and return a 200 status code.
This means a visitor hitting yourdomain.com/random-garbage-url sees your homepage rather than an error page. The browser receives a success status code rather than a 404.
For human visitors, this might seem harmless or even helpful. For search crawlers, it creates serious problems.
The Crawler Trap Problem
When Googlebot follows a broken link to your site and receives a 200 status with homepage content, it believes it found a valid new page. It then follows links on that “new page” and discovers more “pages” that are all actually your homepage returned under different URLs.
If your homepage contains relative links, the crawler compounds errors. It constructs URLs like yourdomain.com/bad-path/link-from-homepage, receives the homepage again, and continues down an infinite rabbit hole.
This infinite loop consumes your crawl budget. Search engines allocate limited resources to crawling each domain. When those resources disappear into fake pages that all return identical content, your real pages don’t get crawled.
The Fix
Create a 404.html file in your project’s root directory. The content can be simple: a message that the page wasn’t found, a link back to the homepage, styling that matches your site.
With this file present, Cloudflare switches to standard behavior. Non-existent paths return the 404 page with a 404 status code. Crawlers correctly identify dead ends and move on.
Check your Cloudflare Pages deployment if you’re running anything other than a true SPA. Even Next.js sites that handle their own routing should include this file to prevent Cloudflare’s SPA fallback behavior from activating.