twitter-bootstrap - 如何解决 “resource requires the request to be CORS enabled… resource has been blocked because the integrity cannot be enforced” 错误

标签 twitter-bootstrap twitter-bootstrap-3 cors subresource-integrity

我在我的项目中使用了 Bootstrap 图标,这给了我错误

Subresource Integrity: The resource 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' has an integrity attribute, but the resource requires the request to be CORS enabled to check the integrity, and it is not. The resource has been blocked because the integrity cannot be enforced.

任何人都可以帮我解决这个问题,当我们转向生产时,图标没有加载。

所以我使用下面的链接作为 Bootstrap 图标

%link{:href => "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css", :integrity => "sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7", :rel => "stylesheet"}/

最佳答案

我认为您缺少 crossorigin="anonymous"

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

When the request doesn't match Same Origin Policy the crossorigin attribute MUST be present for the integrity of the file to be checked. With an integrity set on an external origin and a missing crossorigin the browser will choose to 'fail-open' which means it will load the resource as if the integrity attribute was not set.

Source

关于twitter-bootstrap - 如何解决 “resource requires the request to be CORS enabled… resource has been blocked because the integrity cannot be enforced” 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323268/

相关文章:

css - 为什么将 CSS 类置于其他类之上会完全改变其他不相关的类?

javascript - 如何在密码输入字段旁边显示 div?

javascript - jQuery 在 Bootstrap 按钮组中的按钮之间切换类;在未设置另一个的情况下设置一个并取消设置另一个

angular - 如何在与我的 http 服务器不同的端口上提供 Angular 应用程序

javascript - 受污染的 Canvas ,由于 CORS 和 SVG?

node.js - 使用restify时如何支持cors

javascript - 如何根据 AngularJS 输入类 $invalid 将 Twitter Bootstrap 类设置为错误?

css - 在 2 个不同的 Bootstrap 表上对齐列

css-position - Bootstrap 3.0 : Fixed column

javascript - 一个 ng-model 中的多个指令