我在aws上部署了我的网站,它一直运行良好,直到昨天,但今天,当我注意到一些图标没有加载,然后我检查它,并发现一些交叉起源请求被阻止的错误。如何删除此错误。
完整错误消息:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free-v4-shims.min.css. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free.min.css. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free-v4-font-face.min.css. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free-v4-shims.min.css. (Reason: CORS request did not succeed).
Font Awesome Kit: TypeError: NetworkError when attempting to fetch resource. 145df2f811.js:2:9532
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free.min.css. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ka-f.fontawesome.com/releases/v5.15.1/css/free-v4-font-face.min.css. (Reason: CORS request did not succeed).
当从另一个服务器或网站添加样式表或javascript库时,需要添加Integrity
和CrossOrigin
属性。例如:
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
子资源完整性(SRI)是一种安全特性,它使浏览器能够验证它们获取的资源(例如,从CDN中获取的资源)是否在没有意外操作的情况下被传递。它允许您提供一个获取的资源必须匹配的加密散列。
阅读有关子资源完整性的详细信息
阅读有关跨源资源共享(CORS)的更多信息