I've recently been playing with the Javascript Fetch API. As far as I understand, by default all redirects are handled transparently and in the end I get a response from the last call in the redirect chain.
However, I could invoke fetch with {redirect: 'manual'}, in which case it would return an opaqueredirect response with no usable information. From https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect
An opaque-redirect filtered response is a filtered response whose type is "opaqueredirect", status is 0, status message is the empty byte sequence, header list is empty, body is null, and trailer is empty.
https://fetch.spec.whatwg.org/#http-fetch says that a response gets to be opaqueredirect if redirect is set to 'manual':
Switch on request’s redirect mode:
...
- manual
Set response to an opaque-redirect filtered response whose internal response is actualResponse.
The specification also says:
In other words, an opaque filtered response and an opaque-redirect filtered response are nearly indistinguishable from a network error.
Given all this, why would one set redirect to manual when using the Fetch API? To me it seems pretty useless. Are there use cases where this would be useful?
fetchwas not passing those cookies, so I passed them manually.redirectproperty while trying to implement a log-in form using React Router. After a successful login, I want the server to return 302, but I want to handle it using client-side routing instead of issuing another request to the server. I thought themanualvalue is what I need, but since theopaqueredirectresponse doesn't contain theLocationheader (or any other headers, for that matter), I guess I'll have to do it some other way. I don't understand why it's implemented this way.