Safari xhr (AJAX) requests w/ cross-domain redirec

2019-04-24 22:56发布

问题:

How to reproduce the issue

  1. Make an AJAX request to a server using Safari
  2. Have the server response w/ 302 to a different domain

If either of those conditions is not met, it works.

  1. Use a different browser, it works.
  2. Have the server redirect to same domain, it works.

.

Load: function (in_url, in_cb, in_responseType) {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', in_url, true);
  xhr.onload = function () {
    if (xhr.status === 200) {
      in_cb(null, xhr.response);
    } else {
      in_cb(new Error('[Loader] Could not fetch from: '+in_url+', status: '+xhr.status));
    }
  };
  xhr.onerror = function (error) {
    in_cb(error);
  };

  xhr.send();
}

回答1:

This bug was fixed.
Safari 10.1 (WebKit 603.1.30) was the first version not affected.