title: How to fix XMLHttpRequest has been blocked by CORS policy
body: <p>I have a problem in angular login component when I user NodeJS server REST API
  to connect database (MongoDB)</p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="http://localhost:3000/users/login" rel="nofollow noreferrer">http://localhost:3000/users/login</a>' from origin >'<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: The value of the >'Access-Control-Allow-Credentials' header in the response is 'Content-Type' >which must be 'true' when the request's credentials mode is 'include'. The >credentials mode of requests initiated by the XMLHttpRequest is controlled by >the withCredentials attribute.</p>
  </blockquote>
  
  <p>here is my code in nodejs file (app.js)</p>
  
  <pre><code>var cors = require ('cors');
  app.use(cors({
      origin:['http://localhost:4200','http://127.0.0.1:4200'],
      credentials:true
  }));
  
  app.use(function (req, res, next) {
  
    res.header('Access-Control-Allow-Origin', "http://localhost:4200");
    res.header('Access-Control-Allow-Headers', true);
    res.header('Access-Control-Allow-Credentials', 'Content-Type');
    res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    next();
  });
  </code></pre>
  
  <p>here is git log results :
  <a href="https://prnt.sc/o38w12" rel="nofollow noreferrer">https://prnt.sc/o38w12</a>
  In addition, register functions still works when I submit</p>