如何解决访问 cookie 或存储的请求被阻止,因为它来自跟踪器并且启用了内容阻止

Man*_*God 8 cookies content-security-policy

我在我的网站www.iusefaith.com上使用内容安全政策和谷歌广告。我的 Adsense 没有显示,我在 Firefox Inspector 中收到的错误消息是

请求访问“ https://adservice.google.com/adsid/integrator.js?domain=www.iusefaith.com ”上的 cookie 或存储空间的请求被阻止,因为它来自跟踪器并且启用了内容阻止。

使用 Chrome 我收到以下错误

与跨站点资源关联的 cookie 设置为没有该SameSite属性。未来版本的 Chrome 将仅在跨站点请求中使用SameSite=None和设置 cookie 时才传送 cookie Secure。您可以在应用程序>存储>Cookies 下的开发人员工具中查看 cookie,并查看更多详细信息和

同时我在我的内容安全政策中允许谷歌

<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval'  https://code.jquery.com https://ajax.aspnetcdn.com  *.reftagger.com *.fastly.net *.facebook.com *.youtube.com *.googlesyndication.com *.googleapis.com  *.google-analytics.com *.googletagservices.com *.google.com.gh *.google.com *.doubleclick.net *.vimeo.com *.cloudflare.com *.cloudinary.com *.bootstrapcdn.com; img-src * data:; frame-src *;  ">
Run Code Online (Sandbox Code Playgroud)

因此,我只能在我的主页上看到 google adsense,而在其他页面上却没有。如何修复它并启用 google adsense 显示,而请求访问 cookie 或存储在所有页面上都被阻止?

Yog*_*sch 1

Mozilla 文档中清楚地概述了这一点:

\n
\n

访问 Cookie 或存储的请求被阻止,因为浏览器\n将其识别为来自跟踪器,并且\n启用了内容阻止。

\n

可以通过以下方式更改或删除该权限:

\n
Going to Preferences > Content Blocking and either\n    adding an exception with the Manage Exceptions\xe2\x80\xa6 button\n    choosing the Custom Content Blocking and unchecking the Tracker checkbox\n
Run Code Online (Sandbox Code Playgroud)\n

如果被阻止的资源不需要身份验证,您可以通过向相关元素添加 crossorigin="anonymous" 属性来修复警告消息。\n

\n
\n

该属性的详细信息可以在此页面crossorigin上查看:

\n
\n

crossorigin 属性在<audio><img><link>、\n<script><video>元素上有效,提供对 CORS 的支持,定义元素如何处理跨源请求,从而启用\n对元素获取的数据的 CORS 请求的配置。 \n该属性可以是 CORS 设置\n属性,具体取决于元素。

\n

媒体元素上的跨源内容属性是 CORS 设置\n属性。

\n

这些属性已被枚举,并具有以下可能的\n值:

\n

匿名的

\n

请求使用 CORS 标头,并且凭据标志设置为“同源”。不会通过 cookie、\n客户端 SSL 证书或 HTTP 身份验证交换用户凭据,除非\n目的地是同一来源。

\n
\n
\n

使用凭证

\n

请求使用 CORS 标头,凭据标志设置为“include”,并且始终包含用户凭据。

\n
\n
\n

””

\n

将属性名称设置为空值,例如 crossorigin 或 crossorigin="",与匿名相同。

\n

无效关键字和空字符串将被视为\nonymous 关键字。

\n

默认情况下(即,未指定该属性时),根本不使用 CORS。用户代理不会请求完全\n访问资源的权限,并且在跨源请求的情况下,\n将根据相关元素的类型\n应用某些限制:

\n
\n