CORS问题在请求的资源上不存在“访问控制允许原始标头" [英] CORS problems no 'access control allow origin header' is present on the requested resource
问题描述
这就是我想要做的:
function fetch() {
$http.get("http://www.myapifilms.com/imdb/top")
.success(function(response) {
console.log(response);
$scope.details = response;
});
};
我收到的错误如下:
XMLHttpRequest无法加载 http://www.myapifilms.com/imdb/top .所请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许访问来源' http://localhost:3000 .
XMLHttpRequest cannot load http://www.myapifilms.com/imdb/top. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
我已经在此问题或CORS上进行了很多查找,但似乎仍然无法意识到我必须添加的内容以及在哪个文件中.
I've looked up quite a bit on this issue or CORS but still can't seem to realize what i have to add and in which file(s).
推荐答案
这表示 http://www.myapifilms. com 不允许"localhost"来源访问其数据.
This means that http://www.myapifilms.com does not allow "localhost" origin to access its data.
我可以推荐两种解决方案:
I could recommend two solutions:
-
尝试通过运行
npm install -g http-server
download a chrome plugin(not recommended) but can be handy for testing https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-app-launcher-info-dialog
这篇关于CORS问题在请求的资源上不存在“访问控制允许原始标头"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!