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 |
浏览器兼容性
加载中…