Observed Signal · Aug 5, 2026 · Technical Issue · Source: DEV Community · Impact: 2/5 · Sentiment: Neutral
Cloudflare Worker wildcard route caused R2 custom domain 404
A developer's R2 bucket served via a custom domain returned 404s even though the bucket, DNS, and custom domain were healthy. The cause was an existing Cloudflare Worker route with a wildcard pattern that matched the subdomain; the Worker ran first, looked for the asset, and returned the site's 404 page before R2 could respond. The fix was to remove the wildcard route and enumerate the specific hostnames the Worker should serve (for example example.com/* and www.example.com/*). The post also shows a quick diagnostic (check Content-Type via curl) and warns that Cloudflare product dashboards report each product's health independently, which can hide cross-product routing conflicts.
Practical operational warning for engineers using Cloudflare Workers and R2: routing precedence can silently intercept requests and cause misdiagnosed 404s. Relevant to teams deploying edge workers and object storage custom domains but not industry-shifting.
Track Cloudflare Signals & Market Shifts in Real-Time
Polaris7 autonomous intelligence agents track regulatory filings, primary sources, executive changes, and deal flow 24/7. Create your free Explorer workspace to monitor these entities.
Key Takeaways & Evidence Grounding
- Requests to the R2 custom domain (media.example.com) returned 404 despite the R2 bucket, files, custom domain, and DNS being correctly configured.
- A Cloudflare Worker route using a wildcard pattern (e.g., _.example.com/_) matched the subdomain and took precedence over the R2 custom domain, causing the Worker to return the site's 404 page.
- R2 never received the requests because Workers routing precedence intercepts matching requests before R2.
- Quick diagnostic: curl -sI https://media.example.com/some-file.mp4 — if Content-Type is text/html for a video file, the request is not reaching R2.
- Fix: stop using a wildcard Worker route and explicitly enumerate hostnames the Worker should serve (e.g., example.com/*, www.example.com/*).
Connected Companies & Entities
1 Entity mapped“Title: Cloudflare R2 custom domain returns 404 — a Worker wildcard route was eating it...”
Ontology Mapping & Concepts
Related Market Signals & Shifts
Recent verified developments and strategic activity across this market segment.
Cloudflare Worker Redirect Skipped for Static Assets
A developer observed that a Cloudflare Worker fetch handler containing a www→apex redirect never ran because Cloudflare's Workers static assets feature serves requests that match files in the assets directory directly at the edge, bypassing the Worker. As a result, Worker code (including console.log) only executed for asset-miss requests such as 404s. The author recommends using Cloudflare Redirect Rules for host-level redirects because they run earlier in the request sequence and incur no Worker invocations. An alternative is to enable the assets config setting that forces the Worker to run before the asset lookup, but that increases Worker invocations and cost and should be used only when per-request logic is required.
Serverless Blog on Cloudflare Workers with KV and R2
A developer describes building 1001020, a serverless blog and AI gallery that runs entirely on Cloudflare edge infrastructure. The public site is implemented with Cloudflare Workers for routing and rendering, Cloudflare KV for article and site metadata, and Cloudflare R2 for managed image storage and a browsable gallery. The post explains the architecture, storage tradeoffs (KV as a simple key-value content store), image management via R2, and built-in SEO features such as sitemap and robots.txt. The author frames the system as a compact CMS-like publishing stack that avoids a conventional backend while supporting admin operations, sitemaps, and image cleanup workflows.
Migrated SaaS from Vercel to Cloudflare Workers
A developer migrated VideoCaptions.AI from Vercel to Cloudflare Workers after hitting Vercel CPU limits during a traffic spike. The migration was done in three reversible phases: moving API routes to a Worker, migrating the full SSR site, and a DNS cutover. Key issues encountered included incompatible Node.js libraries (the AWS SDK) requiring aws4fetch, Workers runtime restrictions (no async I/O or setTimeout at module init), oversized server bundles due to client-only WASM leakage, prerendering/manifest issues with the Cloudflare Vite plugin, and auth key/environment gotchas. The author implemented feature toggles, preview/prod environments via wrangler, and a rollback plan. Post-migration benefits reported: lower monthly costs (~$5.50/month), free WAF/DDoS protection, Turnstile, Web Analytics, Workers Traces, and zero egress fees for R2.
Track Real-Time Market Signals & Shifts
Set up custom watchlists to receive automated, evidence-grounded executive digests whenever material signals or shifts occur across your tracked landscape.
