Response-Header CSP for Client Sites
Why AstroWEBTheme uses real Content-Security-Policy response headers with nonces instead of relying on meta-only policy tags.

AstroWEBTheme is designed around real response-header Content-Security-Policy for production sites.
Meta CSP can help in limited cases, but it is not a complete replacement for HTTP headers. Client sites need a policy that works across public pages, SSR routes, dashboards, API endpoints, and generated assets.
Theme Security Goals
The security model aims to:
- avoid
unsafe-inline - use per-request nonces for scripts that need them
- load generated scripts through a manifest
- keep analytics and ads consent-aware
- support Turnstile-ready forms
- keep admin responses no-store
- work naturally on Cloudflare Workers or Pages
Where Configuration Lives
Security configuration is handled in:
src/site/config/security.mjssrc/site/config/functions.mjscore/layouts/base.astrocore/components/FilesToLoadJS.astrosrc/data/manifest/scripts.json
Generated Cloudflare config is managed by:
core/scripts/generate/wrangler-json.mjswrangler.jsonc
Why Agents Should Care
AI agents often add scripts, widgets, analytics, forms, and third-party services. Without a clear CSP model, those changes can silently weaken production security.
When an agent adds a script, it should:
- Check the existing script loader pattern.
- Prefer manifest-managed scripts.
- Preserve nonce handling.
- Update CSP allowlists only when needed.
- Avoid broad directives such as
script-src *. - Build and test after changes.
Consent-Aware Scripts
Analytics and ads should respect the consent banner. The theme separates markup, consent state, and lazy script loading so sites can keep a strict CSP while still supporting common business tooling.
Verification
After security changes, verify:
- page HTML includes nonce attributes where expected
- lazy scripts are promoted by the worker lazy loader
- consent banner controls analytics and ads
- production responses include CSP headers
- no required script depends on
unsafe-inline