Skip to content

chore: serve static files from Cloudflare assets without the Worker - #421

Merged
brunobuddy merged 1 commit into
mainfrom
chore/cloudflare-assets-direct
Oct 20, 2026
Merged

brunobuddy merged 1 commit into
mainfrom
chore/cloudflare-assets-direct

Conversation

@brunobuddy

Copy link
Copy Markdown
Member

Why

The account hit 108k/100k daily Worker requests on the free plan (this site: 58k). run_worker_first: true made every static JSON API request a Worker invocation; static asset requests are free and unlimited.

What

  • run_worker_first limited to /mcp, /api/mcp, /api/v1/validate, /*.html, /*/ (dynamic endpoints + 307→308 clean-URL redirects).
  • Build writes dist/_headers (CORS, cache, noindex, JSON/text content types for /api/v1/* and llms*.txt).
  • Build writes dist/api/v1/404.html with a JSON body, so API misses still get JSON.
  • Alias-host redirects (modelparameters.dev, www.*) are now zone Redirect Rules (already live).

Trade-off: static API hits are no longer logged in Workers Logs.

Verified

wrangler dev: headers, 404s, /mcp, redirects match production. Tests 285/285, tsc clean.

run_worker_first: true counted every JSON API request against the Workers
free-plan quota (58k/day). Only the dynamic endpoints and the clean-URL
redirects now run the Worker; the API headers move to a generated _headers
file, API misses get a JSON 404 from api/v1/404.html, and the alias-host
redirects are zone Redirect Rules.
@github-actions github-actions Bot added the site Website code or tooling label Oct 20, 2026
@brunobuddy
brunobuddy merged commit 879ceaa into main Oct 20, 2026
13 of 14 checks passed
@brunobuddy
brunobuddy deleted the chore/cloudflare-assets-direct branch October 20, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

site Website code or tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant