fix(web): dev-server console noise — public/ assets 404 and blocked blob worker - #804
Conversation
Two dev-only console-noise fixes for the signed-in shell: The Cloudflare Vite plugin serves dev static assets from wrangler's assets.directory (./dist — the production build output), not public/. With run_worker_first ["/*"], every public asset (favicon, /preview/* hero images, robots.txt) hit the Astro worker in dev, matched no route, and rendered 404.astro — prod is unaffected because the build copies public/ into dist/. A small dev-only Vite middleware now answers from public/ before the worker sees the request. Dev tooling occasionally spawns a blob: worker in page context; with no worker-src, the signed-in pages' strict script-src blocked it and logged a CSP error. Allow worker-src 'self' blob: in dev only — app code never creates workers, so prod stays locked down.
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (2)
🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
uploads-web | 4c2a2ca | Commit Preview URL Branch Preview URL |
Aug 23 2026, 05:37 PM |
Summary
Two dev-only fixes for console noise on every
astro devpage load.public/ assets 404 in dev
The Cloudflare Vite plugin routes dev requests through workerd and serves static assets from wrangler's
assets.directory(./dist— the production build output), notpublic/. Withrun_worker_first: ["/*"], every public asset —/favicon.svg, the homepage's/preview/hero-*.webp,/robots.txt, all of it — hit the Astro worker in dev, matched no route, and rendered 404.astro. Prod is unaffected (the build copiespublic/intodist/).Fix: a small dev-only Vite middleware (
servePublicInDevinastro.config.mjs) that answersGET/HEADfrompublic/(with path-traversal guard and a minimal MIME map) before the worker sees the request.configureServeris ignored in builds, so prod behavior is untouched.CSP-blocked blob worker on signed-in pages
Dev sessions intermittently log
Creating a worker from 'blob:…' violates … script-srcon/account/*. No app or dependency code creates workers (verified by grepping the entire loaded module graph); the spawner is dev tooling instrumentation running in page context.signedInCspnow emitsworker-src 'self' blob:underimport.meta.env.DEVonly — same pattern as the existing devimg-srcloopback allowance. Prod CSP is unchanged.Verification
On the local stack (
PORTLESS=0 node scripts/dev-stack.mjs):/favicon.svg,/preview/hero-before.webp,/robots.txtnow 200 with correct Content-Type (all previously 404)/account/workspacesresponse header carriesworker-src 'self' blob:in devtsc --noEmitclean