请求需要预检,不允许遵循跨源重定向AXIOS

时间:2016-12-01 10:17:19

标签: xmlhttprequest cors axios

我尝试从我的前端使用axios登录,但是出现了这个错误:

XMLHttpRequest cannot load http://localhost:8888/auth/login. Redirect from 'http://localhost:8888/auth/login' to 'http://localhost:8888/auth/login/failure' has been blocked by CORS policy: Request requires preflight, which is disallowed to follow cross-origin redirect.

在后端,我正在使用NodeJS并且已经在每条路由之前放置了这个中间件:

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Content-Type");
  next();
});

0 个答案:

没有答案