cloudflare / cloudflare/cloudflare-docs

Pages: Document subdirectory 404.html workaround for SPA + static asset 404 handling

Open
#29,676 1 comment 0 reactions 4 assignees Claimed by @WalshyDev View on GitHub
content:edit documentation product:pages stale
Dominant language
MDX
Stars
5.2k
Forks
16.7k
Avg merge
2d 6h
Merged PRs (30d)
337

Description

### Existing documentation URL(s)

- https://developers.cloudflare.com/pages/configuration/serving-pages/#single-page-application-spa-rendering
- https://developers.cloudflare.com/pages/configuration/serving-pages/#not-found-behavior

### What changes are you suggesting?

The docs describe SPA mode and `404.html` behavior in isolation but don't document how to combine them. A `404.html` placed in a subdirectory (e.g. `/static/`) causes Pages to return `404 Not Found` for unmatched requests under that path, while root-level SPA routing continues to work normally. This is useful for SPAs that serve hashed static assets from a subdirectory — missing assets return a proper 404 rather than a `200 OK` with `index.html` content. A note or example explaining this pattern should be added to the SPA rendering and/or Not Found behavior sections.

### Additional information

This pattern was independently discovered by a customer and documented here: https://community.cloudflare.com/t/angular-chunk-load-error-wrong-mime-type-vol-2/915855

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.