title: Chrome extension jquery Ajax preflight OPTIONS
body: <p>I need to access an API backend of a web app from a Chrome extension. The xhr requests that originate from the webpage itself are always preflighted (OPTIONS). However, I can not get the extension to fire preflight requests, it fires the GET requests and the servers authorization mechanism rejects calls without the OPTIONS first.</p>
  
  <p>I read what is available on stackoverflow and tried to add a random "x-weird-header" in an attempt to send a preflight first but it didn't work.</p>
  
  <p>Another thing I can't understand is, Chrome sends an "Origin" header for calls from the webpage but the request from my extension is missing the "Origin" header. </p>
  
  <p>How can I get OPTIONS sent first? and why is the "Origin" missing in my request?</p>
  
  <p>Thanks!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> $.ajax({
     url : url, /* url is https and it is called from a non ssl but same domain origin*/
       type : 'GET',
       beforeSend : function( xhr ) {
           xhr.setRequestHeader( "Accept", "application/json, text/plain, */*");
           xhr.setRequestHeader( "Authorization", "BEARER " + auth_token );
           xhr.setRequestHeader( "x-weird-header", "utf8" );
       },
       success : function (data) {
         console.log(data);
       },
       error : function (data, errorThrown) {
         console.log(data);
       }
   });</code></pre>
  </div>
  </div>
  </p>