title: Angularjs Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response
body: <p>I know there are lot of duplicate questions.I tried all the solutions given there but still not working.</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://localhost:3000/api/create" rel="nofollow">http://localhost:3000/api/create</a>. Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response.</p>
    
    <p><strong>angularjs code</strong></p>
  </blockquote>
  
  <pre><code>$httpProvider.defaults.headers.common = {};
          $httpProvider.defaults.headers.post = {};
          $httpProvider.defaults.headers.put = {};
          $httpProvider.defaults.headers.patch = {};
          $httpProvider.defaults.headers.get = {};
          $httpProvider.defaults.headers.common['Access-Control-Allow-     Headers'] = '*';
          $httpProvider.defaults.useXDomain = true;
          delete $httpProvider.defaults.headers.common['X-Requested-With'];
  
          $httpProvider.interceptors.push(['$injector',function($injector) {
              var mainFactory = $injector.get('mainFactory');
              return {
                  request: function(config) {
                      var token = mainFactory.getToken();
                      config.headers.Authorization = 'Basic '+token;
                      return config;
                  },
  
                  response: function(response) {
                      return response;
                  }
              };
  }]);
  </code></pre>
  
  <blockquote>
    <p>nodejs code</p>
  </blockquote>
  
  <pre><code>app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header('Access-Control-Allow-Methods','GET,PUT,POST,DELETE,OPTIONS');
  res.header('Access-Control-Allow-Headers','Content-Type,Authorization');
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Accept");
  next();
  });
  </code></pre>