Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.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
Azure 带ASP.NET内核的聚合物,返回“;违反内容安全策略指令“;_Azure_Polymer 1.0_Content Security Policy - Fatal编程技术网

Azure 带ASP.NET内核的聚合物,返回“;违反内容安全策略指令“;

Azure 带ASP.NET内核的聚合物,返回“;违反内容安全策略指令“;,azure,polymer-1.0,content-security-policy,Azure,Polymer 1.0,Content Security Policy,我使用最新版本Polymer 1.7.1创建了一个新的Polymer应用程序 这是一个非常简单的布局,几乎什么也不做,但如果我从我的Windows 10计算机或公共Azure Web角色运行它,所有浏览器(Chrome、Android default和Edge)都会返回此错误: Refused to execute inline script because it violates the following Content Security Policy directive: "defaul

我使用最新版本Polymer 1.7.1创建了一个新的Polymer应用程序

这是一个非常简单的布局,几乎什么也不做,但如果我从我的Windows 10计算机或公共Azure Web角色运行它,所有浏览器(Chrome、Android default和Edge)都会返回此错误:

Refused to execute inline script because it violates the following 
Content Security Policy directive: "default-src 'self'". 
Either the 'unsafe-inline' keyword, 
a hash ('sha256-y9OeFTMzuy/UmFD54M4yHw1fwa70f6ptTlq7FUPrn+M='), 
or a nonce ('nonce-...') is required to enable inline execution. 
Note also that 'script-src' was not explicitly set, 
so 'default-src' is used as a fallback.

Refused to load the stylesheet 'https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,500italic,700,700italic' 
because it violates the following Content Security Policy directive: 
"default-src 'self'". 
Note that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
现在,我确实理解CSP的含义,但这不是我唯一的聚合物项目,但它是唯一一个给我这个问题。 如何将其标记为“安全”并从浏览器中删除这些警告

解决方案 最后,是ASP.NET Core在默认情况下没有添加任何头,这导致Polymer抛出CSC异常

解决方法如下:

        app.Use(async (ctx, next) =>
        {
            ctx.Response.Headers.Add("Content-Security-Policy",
                                     "default-src 'self' * 'unsafe-inline' 'unsafe-eval' data:");
            await next();
        });

你设定CSP了吗?你能修改它吗?不,我没有设置任何实际与CSP相关的内容,是的,我可以修改标题,但仍然不知道你设置了CSP吗?你能修改它吗?不,我没有设置任何实际与CSP相关的内容,是的,我可以修改标题,但仍然不起作用