Nike No'Access-Control-Allow-Origin'标头出现在请求的资源上

时间:2016-03-28 15:06:44

标签: angularjs http nike

我正在尝试使用Angulars $ http请求从Nike商店网站获取当前的男士鞋子并在我自己的网站上显示。

 $http({
        method: 'GET',
        url: 'http://store.nike.com/html-services/gridwallData?country=US&lang_locale=en_US&gridwallPath=mens-clearance-shoes/'
    }).then(function successCallback(response) {
        console.log('success',response);
    }, function errorCallback(response) {
        console.log('error',response);
    }); 

然而,它给了我这个错误。

XMLHttpRequest cannot load http://store.nike.com/html-services/gridwallData?country=US&lang_locale=en_US&gridwallPath=mens-clearance-shoes/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

我知道它是跨域资源共享问题。有没有办法通过这个?我也可以合法地在我的网站上展示他们的清仓产品吗?

1 个答案:

答案 0 :(得分:0)

添加此

   myApp.config(['$httpProvider', function($httpProvider) {
            $httpProvider.defaults.useXDomain = true;
            delete $httpProvider.defaults.headers.common['X-Requested-With'];
        }
    ]);