Menu

Strict CSP for Astro SSR: Per-Request Nonces and Vite Virtual Modules (astro-strict-csp v0.3.0)
📰

Strict CSP for Astro SSR: Per-Request Nonces and Vite Virtual Modules (astro-strict-csp v0.3.0)

DEV Community: astro·Evgenii Zinner·5 days ago
#IMjMA0g8
#devtoastro#devto#dev#astro#strict
Reading 0:00
15s threshold

When I originally built astro-strict-csp and shipped v0.2.0, my website was a pure static Astro build ( output: "static" ). Every HTML file existed on disk at the end of astro build , which meant I could enforce a strict Content Security Policy by scraping inline scripts and styles into external files and hashing them with Subresource Integrity (SRI) before deploying.

Then I migrated ezinner.com to EmDash CMS on Cloudflare Workers and D1.

Moving to a live edge CMS meant flipping Astro from Static Site Generation (SSG) to Server-Side Rendering ( output: "server" ). The moment I made that switch, my existing CSP pipeline hit an obvious wall: in SSR mode, there are no static HTML files at build time to scrape .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.