美文网首页
express 允许跨域访问

express 允许跨域访问

作者: wlianfu | 来源:发表于2018-08-28 10:02 被阅读11次
//设置跨域访问
app.all('*', (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});

相关文章

网友评论

      本文标题:express 允许跨域访问

      本文链接:https://www.haomeiwen.com/subject/aihfwftx.html