大网数据广告活动
网站运营与故障问答

CSP3 Report-To header implementation

· 52CE 我爱测

Issue Many CSP validators like cspvalidator.org tell me that: A draft of the next version of CSP deprecates report-uri in favour of a new report-to directive. I found more information about this on wicg.github.io , but I didn't f…

问题原文

原帖链接 · dargmuesli · CC BY-SA 3.0

Issue

Many CSP validators like cspvalidator.org tell me that:

A draft of the next version of CSP deprecates report-uri in favour of a new report-to directive.

I found more information about this on wicg.github.io, but I didn't find an example / a solution.

Question

How do I properly implement the Report-To HTTP header in Apache 2?

This doesn't throw an error but also does not execute the linked script in Firefox 49 and Chrome 53:

Header set Report-To "{'url': 'https://website.com/csp-report.php', 'group': 'csp-endpoint', 'max-age': 10886400}"

With the Content-Security-Policy header implemented like this:

Header set Content-Security-Policy "default-src 'none'; report-to csp-endpoint"

已采纳解答

原帖链接 · Braiam · CC BY-SA 4.0

There are examples in the draft of the Reporting-Endpoints directive:

Reporting-Endpoints = endpoint-1="https://example.com/reports"

Your rule is correctly created, as in it returns a valid JSON object, but since the Reporting API is still a draft, most UA haven't got around implementing it. You could simply have both, report-uri and Reporting-Endpoints header meanwhile if you want to.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。