Getting the host from a redirected pre-request script response

I am using a pre-request script to log my user into a application (secured with SSO via Cookies but that won’t matter) and the server responses are often redirecting requests which is working fine but is there a way to get the actual Host after a redirect in a pre-request script?

In my case one of the redirected pages contains a relative login action /login but because the host is not anymore (like my original request) but I can’t construct the full login URL because my script technically isn’t aware that it gets the current response from and not and hard-coding this prefix only delays potential problems.

Ideally the response object the request passes to the callback would contain a hint whether the request was a redirect and what the original and new host are so the request callback could use that host to construct valid absolute URL. The easiest alternative would be to make all URL absolute on all websites of course but that’s beyond my reach at the moment.