0

I have a script that sends an http request to an endpoint and that endpoint redirects to another endpoint.

Eg. http://site/endpoint redirects to http://site/endpoint2#ABCD
I want to retrieve (in this situation) ABCD (part after #), but it appears to cut and show only the before # part in req.responseURL. In the console after enabling showing XHR requests or in network monitor it shows the full url of the request.

How can I retrieve the full address of the redirected site? - How can I retrieve the after # part (Clientside not serverside)?

Example (To show that part after # is cut in req.responseURL, not actual redirecting) Console panel displaying "GET https://www.google.com/test#ABCD" and the corresponding URL with the post-# characters cut-off

In web monitor after switching to raw content it also shows that the request was sent to <url>#ABCD Web monitor panel displaying request information, including "GET /test#ABCD"

var req = new XMLHttpRequest();
req.open('GET', '/test#ABCD', false);
req.send(null);
console.log(req.responseURL)
dommilosz
  • 127
  • 13
  • 1
    The part after `#` is never sent to the server, it's just for use in the client. – Barmar Sep 28 '20 at 20:56
  • @Barmar But I don't want to read it on server. I want to read it on client. Server redirects to a specific url with # part and I want to read the full redirection url on client side. – dommilosz Sep 30 '20 at 20:05
  • It should be in `window.location.hash` on the redirected page. – Barmar Sep 30 '20 at 20:06
  • @Barmar ok but it is not as loaded page in browser but as XHR request – dommilosz Oct 01 '20 at 13:04

0 Answers0