Angular2,NodeJS和护照问题

目前,我的Angular2前端运行在localhost:3000上,NodeJS后端(基于KrakenJS)运行在localhost:8000 。 当我input证书时,我调用了this.http.post('http://localhost:8000/login', body, { headers: contentHeaders }) api,但是我在Chrome中得到以下响应:

 XMLHttpRequest cannot load http://localhost:8000/login. The request was redirected to 'http://localhost:8000/', which is disallowed for cross-origin requests that require preflight. 

但是当我调用this.http.post('http://localhost:8000/register', body, { headers: contentHeaders })它一切正常,并执行所有的注册魔术(散列pswd,在数据库中存储细节。 。等等。)。

这是我从(register.js)的简单注册API:

  router.post('/', function (req, res) { if (req.body.email && req.body.password) { var User = require('../../models/user'); User.create({ name: req.body.name, email: req.body.email, password: req.body.password }).then( function() { res.render('user/registered', {registered: true}); }, function() { res.render('user/registered', {registered: false}); } ); } else { res.render('user/registered', {registered: false}); } }); 

这是来自(login.js)的Login api:

  router.post('/', function (req, res) { passport.authenticate('local', { successRedirect: req.session.goingTo || '/', failureRedirect: '/login', failureFlash: true })(req, res); }); 

在主服务器文件中启用CORS:

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