title: Handle HTTP 302 response from proxy in angularjs
body: <p>I have a reverse proxy that checks global authentication for several applications. When the user is disconnected but still trying to use my application, the proxy sends a 302 response :  </p>
  
  <pre><code>HTTP/1.1 302 Found
  Date: Wed, 11 Sep 2013 09:05:34 GMT
  Cache-Control: no-store
  Location: https://other.url.com/globalLoginPage.html
  Content-Length: 561
  Content-Type: text/html; charset=iso-8859-1
  Via: 1.1 my-proxy.com
  Connection: Keep-Alive
  </code></pre>
  
  <p>In angularJs, the error callback is called but the response headers are empty, status is 0 and data is an empty string. So it seems that I really can't do nothing to handle the response...<br>
  I've seen several questions on the subject, and I still don't understand what is going on (CORS because of the proxy or different domain in the location?, 302 browser behavior?).<br>
  In particular there is this part from an answer (<a href="https://stackoverflow.com/a/17903447/1093925">https://stackoverflow.com/a/17903447/1093925</a>):  </p>
  
  <blockquote>
    <p>Note: If your server sets a response code of 301 or 302, you will not be able to get the Location header, as it will be automatically and transparently followed by the XMLHttpRequest object.</p>
  </blockquote>
  
  <p>What about this XMLHttpRequest object?<br>
  In a very old version of Chrome (can't use a newer version) I can see that a corresponding request in the network panel, but it seems to fail as there is no response.<br>
  In the latest version of firefox, there is nothing going on.  </p>
  
  <p>Can I do anything about that, since I can't change the proxy configuration and response?</p>
  
  <p><strong>Update:</strong><br>
  I replayed my scenario today, and thanks to a newer version of firebug, I was able to get more details about what is going on.<br>
  I was not far from the anwser in my question : Cross domain policy.<br>
  Since it is an HTTP request made by my application, the browser denies the following XMLHttpRequest (which in-app looks like the same request). Hence the error and the empty response.<br>
  So I think there is nothing special I can do about it</p>