Closed
Description
When you use redirect="manual" there is not way to get the new URL, i.e. to where response was redirected.
Example for Firefox:
fetch("/account/", {
credentials: 'same-origin',
redirect: 'manual',
}).then(response => {
console.log(response);
});
Server would response with redirect to /login/?next=/account/
.
Here is Javascript Response object:
{
bodyUsed: false,
headers: {},
ok: false,
redirected: false,
status: 0,
statusText: "",
type: "opaqueredirect",
url: "http://localhost:8000/account/"
}
So response.url is the URL I requested.
How could I get the URL where response was redirected to? There is no "redirect_url" and headers are empty.
As far as I understand the specification, with "manual" is meant to handle redirects manually. Then there should be a way to get this new URL and do another request to this new URL.
Here is what server send:
HTTP/1.1 302 Found
X-Powered-By: Express
date: Thu, 14 Jun 2018 09:41:49 GMT
server: WSGIServer/0.2 CPython/3.7.0b5
content-type: text/html; charset=utf-8
location: /login/?next=/account/
x-frame-options: SAMEORIGIN
content-length: 0
vary: Accept-Language, Cookie
content-language: en
connection: keep-alive
How to access this new url /login/?next=/account/
?