Does WebAPI fetch follow redirects?

2019-02-25 06:15发布

问题:

Does fetch follow HTTP 30x redirects?

回答1:

Yes. Check this.

Checking to see if the response comes from a redirected request is as simple as checking this flag on the Response object.

 if (response.redirected) {
   //...
 }

You can disable it:

fetch("awesome-picture.jpg", { redirect: "error" }).then(function(response) {
  //some stuff
}).then(function(imageBlob) {
  //some other stuff
});