var allowCors = function(req, res, next) {
res.header('Access-Control-Allow-Origin', req.headers.origin);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');
res.header('Access-Control-Allow-Credentials','true');
next();
};
app.use(allowCors);//使用跨域中间件
关于跨域问题,后面的博客会有详细讲解!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。








