senternet-site-csp

Configures Content Security Policy headers for Firebase-hosted marketing sites.

Updated May 8, 2026
One-click install
npx skills add https://github.com/MattSenter/senternet-site-skills --skill senternet-site-csp-mattsenter
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: senternet-site-csp
Source: https://github.com/MattSenter/senternet-site-skills/tree/main/.claude/skills/senternet-site-csp
Command: npx skills add https://github.com/MattSenter/senternet-site-skills --skill senternet-site-csp-mattsenter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Marketing sites that load third-party analytics and tracking scripts (GA4, Reddit Pixel, Ahrefs) are exposed to XSS and code-injection risks unless a Content Security Policy restricts which origins can execute scripts, load images, and open connections. Manually writing a correct CSP for a static Firebase-hosted site is error-prone, especially around inline scripts and the nonce-versus-hash tradeoff. ## Core Features & Use Cases - Service-aware policy assembly: Audits the project for GA4, Reddit Pixel, Ahrefs Web Analytics, Firebase, and Google Fonts, then extends each CSP directive only for the services actually present. - Inline script handling: Moves inline <script> blocks into public/ files where possible and computes SHA-256 hashes for any that must remain inline. - Safe rollout workflow: Deploys first in Content-Security-Policy-Report-Only mode on dev, then switches to enforcing mode and verifies the live header with curl. - Next.js track: For server-rendered Next.js on Firebase App Hosting, generates per-request nonces in middleware.ts with 'strict-dynamic' instead of static hashes. - Use Case: After adding GA4 and a Reddit Pixel to a Vite marketing site, run this skill to produce a firebase.json CSP header that allows exactly those origins, test it in report-only mode on the dev deployment, then enforce it in production. ## Quick Start Ask the AI to add a Content Security Policy to the Firebase hosting configuration for this site, covering whichever analytics and tracking services the project currently uses.

Frequently Asked Questions about senternet-site-csp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a Content Security Policy to Firebase Hosting?▼

Add a Content-Security-Policy header entry to the headers array in firebase.json under the ** catch-all source. Define directives like default-src, script-src, and connect-src, then deploy and verify the header with curl -sI against the live domain.

How do I handle inline scripts with a strict CSP?▼

Move inline script blocks into external files in the public directory so they are covered by script-src 'self'. For scripts that cannot be moved, compute a SHA-256 hash of the exact content with openssl or Node and add it to script-src.

Should I use nonces or hashes for CSP on a static site?▼

Use SHA-256 hashes on static hosts like Firebase Hosting, because headers are static strings and a fixed nonce is equivalent to 'unsafe-inline'. Nonces only work when a server generates a fresh value per request, such as Next.js middleware on Cloud Run.

What CSP directives does Google Analytics 4 require?▼

GA4 requires https://www.googletagmanager.com in script-src, https://www.google-analytics.com and the tag manager origin in img-src, and google-analytics.com, analytics.google.com, stats.g.doubleclick.net, and region1.google-analytics.com in connect-src.

How do I test a CSP without breaking my site?▼

Deploy first with the Content-Security-Policy-Report-Only header so violations are logged to the browser console without blocking resources. Browse the full deployed dev site, add any missing origins, then rename the header to Content-Security-Policy to enforce it.

Why is my CSP not applied in local development?▼

The Vite dev server does not read firebase.json, so CSP headers are not enforced locally. All policy testing must be done against a deployed Firebase environment, verified via curl or DevTools network response headers.