title: Angular: CORS preflight response did not succeed
body: <p>Good day everyone,</p>
  <p>I'm having an issue with my users registration app and I hope you guys can help me figured out what's going on:</p>
  <p>I'm using MongoDb, Express, Angular and NodeJs and this is how it looks in app.js (I'm including also the screenshot of the error that shows both in Firefox and Chrome). Thank you in advance</p>
  <p><a href="https://i.stack.imgur.com/ohQeO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ohQeO.png" alt="enter image description here" /></a></p>
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  
  
  var app =express();
  var user_routes = require('./routes/user');
  var follow_routes = require('./routes/follow');
  var publication_routes = require('./routes/publication');
  var message_routes = require('./routes/message');
  
  app.use(bodyParser.urlencoded({extended:false}));
  app.use(bodyParser.json());
  
  app.use((req, res, next) =&gt; {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Authorization, X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Allow-Request-Method');
  res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE');
  res.header('Allow', 'GET, POST, OPTIONS, PUT, DELETE');
  next();
  
  }); 
  
  app.use('/api', user_routes);
  app.use('/api', follow_routes);
  app.use('/api', publication_routes);
  app.use('/api', message_routes);
  
  module.exports = app;
  </code></pre>