拒绝应用内联样式,因为它违反了以下内容安全策略指令:"style-src 'self'" modernizr
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'" modernizr
我在 visual studio 2015 专业版中创建了新的 asp.net mvc 5 项目
我在内容安全策略的布局中添加了元标记,如 -
<meta http-equiv="content-security-policy"
content="default-src 'none'; script-src 'self';
connect-src 'self'; img-src 'self'; style-src 'self';" />
现在,当我 运行 我的应用程序时,我在 chrome 浏览器控制台中收到以下错误 -
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-CwE3Bg0VYQOIdNAkbB/Btdkhul49qZuwgNCMPgNY5zw='), or a nonce ('nonce-...') is required to enable inline execution.
modernizr-2.6.2.js:157
modernizr-2.6 有 6 个错误。2.js:157 一个与脚本有关,即拒绝加载脚本 localhost
我认为我的项目中没有任何内联样式,那么为什么 CSP 拒绝应用错误?
显然 modernizr 要么注入具有某些 CSS 属性的 style
元素,要么注入一些 style
属性;您可以通过更改您的 CSP 政策来处理它:
<meta http-equiv="content-security-policy"
content="default-src 'none'; script-src 'self';
connect-src 'self'; img-src 'self';
style-src 'self' 'sha256-CwE3Bg0VYQOIdNAkbB/Btdkhul49qZuwgNCMPgNY5zw=';" />
我在 visual studio 2015 专业版中创建了新的 asp.net mvc 5 项目 我在内容安全策略的布局中添加了元标记,如 -
<meta http-equiv="content-security-policy"
content="default-src 'none'; script-src 'self';
connect-src 'self'; img-src 'self'; style-src 'self';" />
现在,当我 运行 我的应用程序时,我在 chrome 浏览器控制台中收到以下错误 -
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-CwE3Bg0VYQOIdNAkbB/Btdkhul49qZuwgNCMPgNY5zw='), or a nonce ('nonce-...') is required to enable inline execution. modernizr-2.6.2.js:157
modernizr-2.6 有 6 个错误。2.js:157 一个与脚本有关,即拒绝加载脚本 localhost
我认为我的项目中没有任何内联样式,那么为什么 CSP 拒绝应用错误?
显然 modernizr 要么注入具有某些 CSS 属性的 style
元素,要么注入一些 style
属性;您可以通过更改您的 CSP 政策来处理它:
<meta http-equiv="content-security-policy"
content="default-src 'none'; script-src 'self';
connect-src 'self'; img-src 'self';
style-src 'self' 'sha256-CwE3Bg0VYQOIdNAkbB/Btdkhul49qZuwgNCMPgNY5zw=';" />