通過處理選項在服務器端,我能夠解決問題的要求, This post solved my problem
通過添加的代碼下面一行
app.use(function (req,res,next){
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
res.writeHead(200, headers);
res.end();
} else {
//...
other requests
}
});
的可能的複製[XMLHttpRequest的無法加載....預檢的響應具有無效的HTTP狀態代碼401](https://stackoverflow.com/questions/38326128/xmlhttprequest-cannot-load-response-for-preflight-has-invalid-http-status-c ) – sp00m
如果您試圖使用Angular解決它,那麼什麼都不會發生來幫你。它需要固定的服務器端。這是'CORS'問題。' – Ved
謝謝@ Ved,Vijayanath Viswanathan,sp00m –