// 设置允许跨域访问
app.all('*', function (req, res, next) {
  res.header("Access-Control-Allow-Origin",req.headers.origin || '*');
   //允许的header类型
  res.header("Access-Control-Allow-Headers","Content-Type,Authorization,X-Requested-With"); //跨域允许的请求方式 
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");// 可以带cookies
  res.header("Access-Control-Allow-Credentials",1)
    next();
  
});

  

posted on 2020-11-27 13:54  chenlw101  阅读(620)  评论(0编辑  收藏  举报