我正在使用Eve和AngularJS中的API開發應用程序。 爲了避免CORS問題,我做了一個簡單的NodeJS服務器來服務我的靜態文件。 然而,即使通過編寫'X_DOMAINS': '*'
(我使用Curl測試過,它工作)來允許我的Python Eve API上的所有域名後,當我想用$http
調用API時,我在瀏覽器中發現了問題。CORS使用Eve和AngularJS的問題
這是我在Chrome中出現錯誤:
XMLHttpRequest cannot load http://localhost:5000/regions. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
我甚至在我的節點的應用程序寫到這,即使我想這將是無用的:到目前爲止
app.all('/*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type");
res.header("Access-Control-Allow-Methods", "GET, POST","PUT");
next();
});
沒有奏效, 先謝謝您的幫助!