且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用axios收到400错误的错误请求

更新时间:2022-02-10 21:20:10

对于每个发布请求,客户端首先发送一个OPTIONS请求,以检查服务器是否准备好接受连接.您还应该允许服务器接受选项请求.如果不允许,请在节点服务器的情况下使用以下行

For every post request, the client first sends an OPTIONS request to check whether the server is ready to accept the connection. You should also allow the server to accept options request. If you have not allowed use the below lines in case of node server

app.use(function(req, res, next) {
   res.header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
      next();
});