title: AngularJS and Cross Domain POST
body: <p>i have a question regarding CORS requests with HTTP Authorization header:</p>
  
  <p>It seems to me that web browser is not sending Authorization header with POST request, is there any way around this?</p>
  
  <p>Here is my Angular code:</p>
  
  <pre><code>var app = angular.module('app', [])
      .config(['$httpProvider', function($httpProvider) {
          $httpProvider.defaults.useXDomain = true;
          delete $httpProvider.defaults.headers.common['X-Requested-With'];
      }]);
  
      app.controller('ctrl', function ($scope, $http) {
          $scope.insert = function () {
  
              $http.post('http://my.api.com/Insert',
                  {
                      headers: {
                          'Authorization': 'Basic dGVzdDp0ZXN0',
                          'Content-Type': 'application/x-www-form-urlencoded'
                      },
                      data: {
                          'Code': 'test data'
                      },
                      withCredentials: true
                  });
          };
      });
  </code></pre>
  
  <p>On server side i have this in my web.config</p>
  
  <pre><code>&lt;httpProtocol &gt;
    &lt;customHeaders&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Headers" value="Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With" /&gt;
      &lt;add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" /&gt;
      &lt;add name="Access-Control-Allow-Credentials" value="true" /&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  </code></pre>