2016-03-28 35 views
-1

我試圖從耐克商店網站使用Angulars $ http請求獲得當前男士清倉鞋並將其顯示在我自己的網站上。耐克沒有「訪問控制允許來源」標題出現在請求的資源

$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. 

我知道它是跨源的資源共享issuse。有沒有辦法通過這個?我也可以合法地在我的網站上展示他們的清關產品嗎?

+0

*「和也可以我在法律上展示自己的產品清除我的網站上?」 *我們不能回答這個問題。 *「有沒有辦法通過這個」*是的,就像繞過CORS限制的許多其他相同問題所描述的一樣。 –

+0

爲什麼不呢?他們的api是公開的,我可以在我自己的網站上使用它嗎?我應該在stacklaw中提問嗎? –

回答

0

添加此

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

仍然無法正常工作CORS錯誤 –

+0

哪個服務器正在運行? –

+0

抱歉沒有看到。我正在運行節點服務器。我能夠使用jQuery ajax調用來獲取數據。 –

相關問題