title: How to handle preflight CORS request using Node server?
body: <p>I have configured CORs in my Node server like below.</p>
  
  <pre><code>var originsWhitelist = [
    'http://localhost:4200'     //this is my front-end url for development
  
  ];
  var corsOptions = {
    origin: function(origin, callback){
          console.log(origin);
          var isWhitelisted = originsWhitelist.indexOf(origin) !== -1;
          console.log(isWhitelisted);
          callback(null, isWhitelisted);
    },
    credentials:true
  }
  
  app.use(cors(corsOptions))
  </code></pre>
  
  <p>And I am sending json data from Angular frontend, but during that I am getting error like this,
      OPTIONS <a href="http://localhost:30000/api/addProfile" rel="nofollow noreferrer">http://localhost:30000/api/addProfile</a> 0 ()</p>
  
  <p>And My request header is,</p>
  
  <pre><code>Provisional headers are shown
  Access-Control-Request-Headers: content-type
  Access-Control-Request-Method: POST
  Origin: http://localhost:4200
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
  </code></pre>
  
  <p>So, I have other post request in which I am sending multipart/from data but it works fine while this request sends error and response is unknown error.</p>