有没有人在使用 Google Chrome 和 SRI Hash 时遇到过这个问题,它一直在控制台窗口中抛出相同的错误:
Failed to find a valid digest in the 'integrity' attribute for resource 'https://fonts.googleapis.com/css?family=Indie+Flower' with computed SHA-256 integrity 'yxJPuU/cJi0/8FoS+agssT/MtC4P3SGuU+JOzbTejqQ='. The resource has been blocked.
我正在从 https://report-uri.io/home/sri_hash 生成代码并且也尝试过 https://www.srihash.org/
根据这个网站 https://glebbahmutov.com/blog/subresource-integrity/ 作者有同样的问题,所以添加了多个哈希值,这就是我所拥有的
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Indie+Flower" integrity="sha256-CoGIUDlbZltnYk6u/wQKXOszdOOWImA1XzSERnNzHlc= sha384-vk+perBz0d5g0G+x7+4BxElvHeiaLNX7jegOI63Bg53TxNYaUzLGEsSQ4AmIwVr4 sha512-h+9Z3+9s3jtPJjXU9phAXFQwYYFSYhXlnkPwkuubLFf5kfeXWIRC32YkRdB08xmut/dJG/RjPoiR/r4DAtm3PQ==" crossorigin="anonymous">
最佳答案
这必须处理 Google 字体根据浏览器提供不同文件的事实。因此,它会根据用户使用的浏览器进行不同的哈希处理。
以下是 Google 提供的一些关于他们是否会调整系统以支持它的信息。 https://github.com/google/fonts/issues/473
关于google-chrome - 谷歌浏览器 SRI 哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44043585/