2016-01-19 18 views
0

試圖請求CORS請求與代碼:如何使用&符號休息收集處理標題「訪問控制 - 允許來源」?

export default Collection.extend({ 
    model: person, 
    url() { 
    return 'http://127.0.0.1:5000/person/' 
    }, 

    ajaxConfig: function() { 
     return { 
      headers: { 
       'Access-Control-Allow-Origin': 'http//:127.0.0.1:3000' 
      }, 
      xhrFields: { 
       withCredentials: false 
      } 
     }; 
    }, 
}) 

我發送請求與訪問http //:127.0.0.1:3000但如果使用*我仍然得到以下錯誤

XMLHttpRequest cannot load http://127.0.0.1:5000/person/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. 

如何處理這種請求?

回答

0

而不是你的收集發送'Access-Control-Allow-Origin': 'http//:127.0.0.1:3000'在它的請求標題,你的服務器在http://127.0.0.1:5000需要發送它的響應頭到飛行前的請求。

如果您可以提供有關服務器設置的一些詳細信息,我可以幫助您瞭解如何將標題添加到響應中。

相關問題