title: jQuery file upload: Setting headers for HTTP OPTIONS in cross browser upload
body: <p>Using jQuery file upload, I'm uploading a file to a third-party server that requires token authentication for all incoming requests. Before the upload, the browser sends an OPTIONS request to check for cross-domain authorization. That request fails with a 401 because it doesn't contain the token. How can I add an "Authorization: Token " header to that request?</p>
  
  <p>In curl this works:
  <code>curl -X OPTIONS https://api.example.com -H 'Authorization: Token &lt;TOKEN&gt;'</code></p>
  
  <p>I tried the following three options, without luck:</p>
  
  <pre><code>  $("#file-upload").fileupload({
        beforeSend: function(xhr) {
          xhr.setRequestHeader("Authorization", "Token " + TOKEN);
        },
        xhrFields: {
          "Authorization": "Token " + TOKEN
        },
        requestHeaders: {
          "Authorization": "Token " + TOKEN
        },
    });
  </code></pre>