| 8 | 8 | | # default assets-first router would short-circuit pre-rendered HTML before |
| 9 | 9 | | # the middleware ever runs. |
| 10 | 10 | | # |
| 11 | | - | # Pattern form (vs the simpler `true`) excludes paths the worker has nothing |
| 12 | | - | # to do for: bundled assets, client modules, and any path with a static-file |
| 13 | | - | # extension. Those bypass the worker entirely and Cloudflare's `_headers` |
| 14 | | - | # rules still apply directly. URLs without an extension (`/`, |
| 15 | | - | # `/router/file-router`, `/.well-known/*`, `/mcp`, …) fall through to the |
| 16 | | - | # worker so content negotiation, the agent-discovery middleware, and SSR |
| 17 | | - | # routes keep working. |
| 11 | + | # Pattern form (vs the simpler `true`) bypasses the worker for paths that |
| 12 | + | # are unambiguously served by ASSETS: bundled binary/font assets, the |
| 13 | + | # prerendered `*.md` siblings of every page (worker has no route for |
| 14 | + | # them), and `*.txt` files like `robots.txt` / `llms.txt`. We deliberately |
| 15 | + | # do NOT exclude `.json`, `.html`, or `.xml`: the agent-discovery |
| 16 | + | # middleware serves dynamic `.json` endpoints under `/.well-known/` whose |
| 17 | + | # paths are never on disk, and the content-negotiation middleware needs |
| 18 | + | # the worker to run for HTML requests with `Accept: text/markdown`. For |
| 19 | + | # the real static `.json` assets (e.g. `/schema.json`) and `.xml` |
| 20 | + | # (`/sitemap.xml`), the worker's edge handler proxies the request to |
| 21 | + | # `env.ASSETS.fetch()` and only falls through to SSR on a genuine 404, so |
| 22 | + | # worker-first costs one cheap proxy hop and Cloudflare's `_headers` rules |
| 23 | + | # still apply (worker-proxied, not worker-generated). |
| 24 | + | # |
| 25 | + | # Any dynamic endpoint that *must* be served at an excluded extension |
| 26 | + | # (e.g. `.well-known/agent-skills/react-server/SKILL.md`) has to be |
| 27 | + | # materialized into the static-assets directory at build time so the |
| 28 | + | # ASSETS-only path can serve it. The agent-discovery middleware is then |
| 29 | + | # only the dev-mode fallback. |
| 18 | 30 | | [assets] |
| 19 | 31 | | run_worker_first = [ |
| 20 | 32 | | "/*", |