加载本地文件时跨域请求被阻止 [英] Cross-Origin Request Blocked when loading local file

查看:228
本文介绍了加载本地文件时跨域请求被阻止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在开发一个网站,无法在Firefox中显示我的字体图标.除firefox以外的所有浏览器都可以加载并显示我的字体图标,但是在firefox上却出现以下错误:

I am currently developing a website and have trouble showing my font-icons in firefox. every browser except for firefox can load and show my font-icons, but on firefox I get the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/Me/Desktop/website/resources/dist/css/fonts/themify.ttf. (Reason: CORS request not http).

文件路径正确,因为当我输入上面列出的URL时,浏览器允许我下载文件.有人知道为什么我会收到此错误吗?

the path of the file is correct, as the browser lets me download the file when I enter the above listed URL. Anybody knows why I get this error?

推荐答案

如注释部分所述,我安装了Web服务器.就我而言,我使用的是tomcat8,即使在Firefox中,我也可以显示图标.

As mentioned in the comment section, I installed a web server. In my case I used tomcat8 and using that I was able to display the icons even in firefox.

这篇关于加载本地文件时跨域请求被阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆