title: CORS Prelight Issue
body: <p>I am getting following error for a jQuery call to my azure app proxy </p>
  
  <p>XMLHttpRequest cannot load <a href="https://azentsearchdev01-mytenant.msappproxy.net/search?text=mytext&amp;type=json&amp;callback=json_callback" rel="nofollow noreferrer">https://azentsearchdev01-mytenant.msappproxy.net/search?text=mytext&amp;type=json&amp;callback=json_callback</a>. 
  Response for preflight is invalid (redirect)</p>
  
  <p>This is what I am doing</p>
  
  <ol>
  <li><p>From mytenantsite.sharepoint.com, making a call jQuery call to an Azure app on the folliwing url - <a href="https://azentsearchdev01-mytenant.msappproxy.net" rel="nofollow noreferrer">https://azentsearchdev01-mytenant.msappproxy.net</a></p></li>
  <li><p>As part of the call, I am setting an authorization header with authentication token (access token) from Azure AD</p></li>
  <li><p>The jQuery call is fails with a 302 redirect to <a href="https://login.microsoftonline.com/" rel="nofollow noreferrer">https://login.microsoftonline.com/</a></p></li>
  </ol>
  
  <p>Here is my code</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>//authorization context
  var resource = 'https://azentsearchdev01-mytenant.msappproxy.net/';
  var endpoint = 'https://azentsearchdev01-mytenant.msappproxy.net/search?text=mytext&amp;type=json&amp;callback=json_callback';
     
  var authContext = new AuthenticationContext({
          instance: 'https://login.microsoftonline.com/',
          tenant: 'mytenant.onmicrosoft.com',
          clientId: 'guid for client id',
          postLogoutRedirectUri: window.location.origin,
          cacheLocation: 'localStorage'
      });
  
  //save tokens if this is a return from AAD
  authContext.handleWindowCallback();
  
  var user = authContext.getCachedUser();
  if (user) {  //successfully logged in
      authContext.acquireToken("https://graph.windows.net", function (error, token) {
        if (error || !token) {
           jQuery("#loginMessage").text('ADAL Error Occurred: ' + error);
               return;
        }
  
        $.ajax({
          type: 'GET',
       url: endpoint,
    headers: {
             Accept: 'application/json',
             },
      beforeSend: function(xhr, settings) { 
     xhr.setRequestHeader('Authorization','Bearer ' + token); 
       }
          }).done(function (data) {
                  jQuery("#loginMessage").text('success');
                 }).fail(function (err) {
                  jQuery("#loginMessage").text('Error calling endpoint: ' + err.statusText); **--&gt;This is where the code lands**
                 }); </code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>So far -</strong></p>
  
  <p>Based on what I have read, this is known gap in current state of how browsers handle a CORS preflight redirects. Reference <a href="https://stackoverflow.com/questions/34949492/cors-request-with-preflight-and-redirect-disallowed-workarounds/39728229#39728229">link</a>.</p>
  
  <p><strong>Question -</strong></p>
  
  <p>Are there any options to make a successful call to an app that requires cors preflight redirect?</p>