報告端點
HTTP Reporting-Endpoints 響應頭允許網站管理員指定一個或多個端點,這些端點可以接收由 Reporting API 生成的報告。
例如,這些端點可以作為傳送 CSP 違規報告、Cross-Origin-Opener-Policy 報告或其他通用違規報告的目標。
當用於報告 內容安全策略 (CSP) 錯誤時,此標頭與 Content-Security-Policy 標頭的 report-to 指令一起使用。有關設定 CSP 報告的更多詳細資訊,請參閱 內容安全策略 (CSP) 文件。
注意: 此標頭替換了用於宣告端點的 Report-To 已棄用 ,應優先使用此標頭。
| 標頭型別 | 響應標頭 |
|---|---|
| 禁止的標頭名稱 | 否 |
| CORS 安全列表響應標頭 | 否 |
語法
http
Reporting-Endpoints: <endpoint>
Reporting-Endpoints: <endpoint>, <endpoint>
- <endpoint>
-
格式為
{endpoint-name}="{URL}"的報告端點。端點必須具有格式為endpoint-name-"{report-URL}"的有效 URI 字串,並且非安全端點將被忽略。可以提供以逗號分隔的端點列表。
示例
設定 CSP 違規報告端點
以下示例演示瞭如何將 Reporting-Endpoints 響應標頭與 Content-Security-Policy 標頭結合使用,以指示 CSP 違規報告發送到的位置
http
Reporting-Endpoints: csp-endpoint="https://example.com/csp-reports"
Content-Security-Policy: default-src 'self'; report-to csp-endpoint
指定多個報告端點
可以指定多個端點,這些端點可用於不同型別的違規報告
http
Reporting-Endpoints: csp-endpoint="https://example.com/csp-reports",
hpkp-endpoint="https://example.com/hpkp-reports"
規範
| 規範 |
|---|
| Reporting API # header-field-registration |
瀏覽器相容性
BCD 表格僅在啟用 JavaScript 的瀏覽器中載入。