Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Security hCaptcha的内容安全策略头/元不工作_Security_Web_Browser_Content Security Policy - Fatal编程技术网

Security hCaptcha的内容安全策略头/元不工作

Security hCaptcha的内容安全策略头/元不工作,security,web,browser,content-security-policy,Security,Web,Browser,Content Security Policy,我试图将hCaptcha嵌入到网站中,但它不会接受我在meta head中设置的内容安全策略,也不会直接在Chrome和FireFox中设置header <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com; frame-src

我试图将hCaptcha嵌入到网站中,但它不会接受我在meta head中设置的内容安全策略,也不会直接在Chrome和FireFox中设置header

<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com; frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com; style-src 'self' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com" />
标题的字符串相同(使用Go)。现在我只是想让meta标签正常工作。这是我在Chrome中遇到的错误:

在FireFox中:


我做错了什么?我认为它是从最新的Chrome和FireFox更新开始的,之前就已经成功了。

通过配置和使用不同的主机名解决了这个问题。将localhost.com添加到/etc/hosts并访问您在localhost.com:port上的页面。

噢,您在localhost上调试了ªCaptcha吗?hCAPTCHA禁止
localhost
127.0.0.1
:。请注意,这个页面的CSP是错误的。是的,我试过了。如果您向/etc/hosts添加一个自定义主机名,它就可以工作了,这对我来说很好。不需要CPS设置。
script-src 'self' 'unsafe-eval' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com;
frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com;
style-src 'self' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com