在app.js中加入以下代码:
express解决跨域post请求变成OPTIONS

代码如下:
app.all(’’, function(req, res, next) {
res.header(“Access-Control-Allow-Origin”, "
");
res.header(“Access-Control-Allow-Headers”, “X-Requested-With,Content-Type”);
res.header(“Access-Control-Allow-Methods”,“PUT,POST,GET,DELETE,OPTIONS”);
next();
});

相关文章:

  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2021-12-05
  • 2021-11-01
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案