Is it possible to get all the urls in a chain of redirects for a given link on the client-side using JavaScript?
Question: I am currently working on a JavaScript chrome extension and would like to be
able to send all the redirects for a given link that matches a certain
criteria. I would like to do this client side invisibly and send the data back
to an endpoint. There are several ways to do this in other server-side
languages (I would like to basically have the functionality of the following
python script)

    
    
    import requests
    response = requests.get(domain)
    redirects = list()
    for r in response.history:
        redirects.append(r.url)
    

Is there anyway to extract this sort of information invisibly on the client-
side, preferably using JavaScript/some JS library?

Thanks in advance for your time!


Answer: This is not possible from the client side using JavaScript. You can send a
HTTP request to a certain URL using
[XMLHttpRequest](https://developer.mozilla.org/en-
US/docs/Web/API/XMLHttpRequest), but it will automatically follow redirects
down to the final destination. There is not way to retrieve the redirection
history. Also, browsers prevent sending requests to different origins as per
the [Same-origin policy](https://en.wikipedia.org/wiki/Same-origin_policy).

