Reporting-Endpoints 標頭

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

HTTP Reporting-Endpoints 響應標頭允許網站管理員指定一個或多個端點,這些端點可以接收由 Reporting API 生成的報告。

這些端點可用於,例如,作為傳送 CSP 違規報告、Cross-Origin-Opener-Policy 報告或其他通用違規報告的目標。

當用於報告 內容安全策略 (CSP) 錯誤時,該標頭與 Content-Security-Policy 標頭的 report-to 指令結合使用。有關設定 CSP 報告的更多詳細資訊,請參閱 內容安全策略 (CSP) 文件。

注意:此標頭取代了用於宣告端點的 Report-To 已棄用 ,應優先使用。

頭型別 響應頭
禁止請求頭
CORS-safelisted 響應頭

語法

http
Reporting-Endpoints: <endpoint>
Reporting-Endpoints: <endpoint>, …, <endpointN>
<endpoint>

一個報告端點,格式為 <endpoint-name>="<URL>"。端點必須在帶引號的字串中包含有效的 URI(例如,my-endpoint="https://example.com/reports"),並且非安全端點將被忽略。可以提供逗號分隔的端點列表。

示例

設定 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",
                     permissions-endpoint="https://example.com/permissions-policy-reports"

規範

規範
Reporting API
# header-field-registration

瀏覽器相容性

另見