title: Angular $http is sending OPTIONS instead of PUT/POST
body: <p>I am trying to Update/Insert data in a MySQL database through a PHP backend. I'm building the Front End with AngularJS and using the <code>$http</code> service for communicating with the REST API.</p>
  
  <p>My setup looks like this:</p>
  
  <p><strong>I'm setting the header via the $httpProvider:</strong></p>
  
  <pre><code> $httpProvider.defaults.withCredentials = true;
   $httpProvider.defaults.headers = {'Content-Type': 'application/json;charset=utf-8'};
  </code></pre>
  
  <p><strong>And the POST-Call looks like this:</strong></p>
  
  <pre><code>   return $http({
        url: url,
        method: "POST",
        data: campaign
      });
  </code></pre>
  
  <p><strong>The Dev Console in Chrome shows me this:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/awnpk.png" alt="enter image description here"></p>
  
  <p>When I change from POST to PUT, I'm sending an OPTIONS call instead a PUT. And the content-type switches just to <code>content-type</code>.</p>
  
  <p><strong>My  request payload is send as an object:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/9ojcZ.png" alt="enter image description here"></p>
  
  <blockquote>
    <p>How do I set my header properly?</p>
  </blockquote>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The PHP backend sets some headers:</p>
  
  <pre><code>   $e-&gt;getResponse()
                -&gt;getHeaders()
                -&gt;addHeaderLine('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
  
     $e-&gt;getResponse()
                -&gt;getHeaders()
                -&gt;addHeaderLine('Access-Control-Allow-Origin', '*');
  </code></pre>
  
  <blockquote>
    <p>Is there something missing?</p>
  </blockquote>