Azure 应用服务上的 CDN - 可能有 Content-Security-Policy-Report-Only header?

CDN on Azure App Services - possible to have Content-Security-Policy-Report-Only header?

是否可以在 Azure 应用服务的 CDN 上为 Content-Security-Policy-Report-Only 实施 header?

我无法用空白值添加它,如果我添加一个对 Content-Security-Policy 有效的值,例如然后它也失败了。

if I add a value that is valid for Content-Security-Policy, e.g. then it also fails.

Content-Security-Policy-Report-Only header 应该有一个强制性的 report-urireport-to 指令,否则它会在控制台中显示一个警告,你的 header 什么都不做.

Content-Security-Policy-Report-Only header 不阻止,只是发送有关阻止某些内容的意图的报告。因此,您可以找出遗漏的来源并将它们添加到适当的指令中。
您可以使用入门 CSP,例如:

default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; report-uri https://YourReportHandler.com/csp-endpoint

然后检查违规报告并将阻止的源添加到启动 CSP。

注意。要处理违规报告,您可以使用 raygun.com / report-uri.com and similar third-party services or handle CSP report on your own, for example Save reports to Azure Table storage.