Tool Hub

CSP 產生器

根據每個網域的規則產生 Content Security Policy 標頭

DirectiveSources
default-src
script-src
style-src
img-src
connect-src
font-src
frame-src
media-src
Content-Security-Policy 標頭
default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; font-src 'self'; frame-src 'none'; media-src 'self'

按一下下方每個指令下的晶片來附加常用的來源權杖。

使用方法

  1. Review the directives table and type or paste sources into each directive row (script-src, style-src, img-src, etc.)。
  2. Click the source chips beneath each row (such as 'self', unsafe-inline, data:) to append common tokens quickly。
  3. Toggle between Minified and Pretty output views to suit your use case。
  4. Copy the generated Content-Security-Policy header value and paste it into your server configuration or meta tag。

範例

  • Adding 'self' and https://cdn.example.com to script-src produces script-src 'self' https://cdn.example.com in the header output。
  • Leaving all directives empty and adding only default-src 'none' produces a strict deny-all baseline policy。

生產環境使用前請驗證輸出。無擔保 — 參見 條款.