在所有路由之前添加
app.all("*",function(req,res,next){
res.header("Access-Control-Allow-Origin","*");
res.header("Access-Control-Allow-Headers","X-Requested-With,content-type,Autherization");
res.header("Access-Control-Allow-Methods","POST,GET");
next();
});
转载内容,请标明出处,谢谢!