1. 跨域
app.all("*", function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "content-type,Authorization"); // Authorization为你添加的请求头中的字段如(headers:{ "Authorization" : "ssss"});注意!不能用*号,否则safari和火狐不认识
res.header("Access-Control-Allow-Methods", "DELETE,PUT,POST,GET,OPTIONS");
if (req.method.toLowerCase() == 'options') {
res.send(200);
} else {
next();
}
});