title: CORS that require preflight, using passport, express angularjs
body: <p>I am currently implementing an app that uses express and passport on the server side. Every time a user tries to log in, the passport authenticate is activated, having two parameters - <code>successRedirect</code> and <code>failureRedirect</code>.</p>
  
  <pre><code>app.post('/login',
     passport.authenticate('local', {
     successRedirect: '/',
     failureRedirect: '/login',
   })
  );
  </code></pre>
  
  <p>I have the following headers </p>
  
  <pre><code>app.use(function(req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
    res.setHeader('Access-Control-Allow-Credentials', true);
    next();
  });
  </code></pre>
  
  <p>My server has URL : <a href="http://localhost:9998" rel="nofollow">http://localhost:9998</a>
  And the application is on : <a href="http://localhost:9000" rel="nofollow">http://localhost:9000</a>
  Whenever I get to the place <code>successRedirect</code> has to be rendered I get the following error :</p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost:9998/login. The request was redirected to 'http://localhost:9998/', which is disallowed for cross-origin requests that require preflight.
  </code></pre>