字体被 firefox Cross-Origin Request Blocked 阻止:同源策略不允许在 firefox 读取远程资源

Fonts are blocked by firefox Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at firefox

当我在浏览器中打开我的 html 文件时,字体被 firefox 阻止,我在其他浏览器上没有任何问题,这只发生在 mozila firefox 上。

错误:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resourceat file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/WebY ekan.woff. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/font awesome-webfont.woff2?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/font awesome-webfont.woff?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/fontawesome-webfont.ttf?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/dinar.woff. (Reason: CORS request not http).

您收到 CORS 错误的原因可能是因为您是通过网络路径 file:///C:/... 而不是实际的 HTTP 请求加载字体。

disallows reading the remote resourceat file:

此消息实质上意味着我们发现您有要加载的内容,但我们不允许访问它,因为它是我们无权请求的网络驱动器上的本地文件资源。

您可能可以通过正确引用您的资源来绕过此错误,因此与其指向 file:///C://,不如从包含该网站的根文件夹开始并从那里请求它们,例如../website/assets/fonts/font-file.ttf。但这是一个大胆的猜测,因为我不知道您正在使用什么技术堆栈进行开发。

您可以在此处阅读更多相关信息:https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp