title: $http.post Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers error
body: <p>I'm working on a app using Ionic Framework. </p>
  
  <p>On the backend i wrote a Flask Application for api which looks like below:</p>
  
  <pre><code>@API.route("/saverez",methods=["POST","OPTIONS"])
  @crossdomain(origin='*', headers="*",methods="*")   
  @render_api
  def saver():
   .....
  </code></pre>
  
  <p>I got errors while posting json to api.</p>
  
  <pre><code>var headers = {
                      'Access-Control-Allow-Origin' : '*',
                      'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS',
                      'Accept': 'application/json'
                  };
  
                  $http({
                      method: "POST",
                      headers: headers,
                      url: url+ '/api/saverez',
                      data: $scope.form
                  }).success(function (result) 
                      console.log(result);
                  }).error(function (data, status, headers, config) {
                      console.log(data);
                      console.log(status);
                      console.log(headers);
                      console.log(config);
                  });
  </code></pre>
  
  <p>So this gives me the error: </p>
  
  <pre><code>XMLHttpRequest cannot load http://myurl/api/saverez. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers. 
  </code></pre>
  
  <p>I googled it and then i found this snippet:</p>
  
  <p><a href="http://flask.pocoo.org/snippets/56/" rel="nofollow">http://flask.pocoo.org/snippets/56/</a></p>
  
  <p>I also added headers to my nginx conf like below:</p>
  
  <pre><code>location ~* \.(eot|ttf|woff)$ {
      add_header Access-Control-Allow-Origin *;
  }
  </code></pre>
  
  <p>Tried everything in that documentation and also evertyhing i found on google but sadly it didn't do any good.</p>
  
  <p>How can i set the right headers for all origins ? I also use google pagespeed does it can cause this issue ?</p>
  
  <p>Thanks in advance.</p>
  
  <p>--- EDIT ---
  Chrome network output</p>
  
  <pre><code>Remote Address:myip
  Request URL:http://myurl/api/saverez
  Request Method:OPTIONS
  Status Code:200 OK
  Request Headersview source
  Accept:*/*
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8
  Access-Control-Request-Headers:access-control-allow-origin, accept, access-control-allow-methods,          content-type
  Access-Control-Request-Method:POST
  Cache-Control:no-cache
  Connection:keep-alive
  Host:myurl
  Origin:http://192.168.1.46:8100
  Pragma:no-cache
  Referer:http://192.168.1.46:8100/
  User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML,     like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53
  Response Headersview source
  Access-Control-Allow-Credentials:true
  Access-Control-Allow-Headers:*
  Access-Control-Allow-Methods:*
  Access-Control-Allow-Origin:*
  Access-Control-Max-Age:21600
  Allow:POST, OPTIONS
  Content-Length:0
  Content-Type:text/html; charset=utf-8
  Date:Thu, 28 Aug 2014 13:26:11 GMT
  Server:nginx/1.6.0
  </code></pre>