CORS问题在请求的资源上不存在“访问控制允许原始标头" [英] CORS problems no 'access control allow origin header' is present on the requested resource

查看:493
本文介绍了CORS问题在请求的资源上不存在“访问控制允许原始标头"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想要做的:

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

下载chrome插件(不推荐),但可以方便地测试

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屋!

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