I'm executing a fetch request with the FetchClient (through an Aurelia wrapper).
The fetch client has three modes:
Follow, Error and Manual (I'll discard error for this question)
If I use follow, the fetch client automatically follows the redirection. The problem is that my original request uses basic auth. It works for the original request, but the redirected URL fails with those basic auth credentials.
If I use the "manual" mode, it doesn't follow through, but I don't get access to the "Location" of the redirected resource and I can't get the proper URL for the redirected resource.
How can I work around this?
It would either be a mode where I get access to the complete response, or an interceptor that allows me to modify the headers before requesting the redirected resource.
You can check the url
property of the response when redirected
property is true
https://developer.mozilla.org/en-US/docs/Web/API/Response/url
fetch("someUrl")
.then(r=>{
if(r.redirected){
const redirectedToUrl = r.url
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With