The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 717 other subscribers

Some links on finding the redirection target of a URL from within a web-browser

Posted by jpluimers on 2026/08/26

Likely what I want is not possible because of CORS or CSP (both security features, often mixed up in writings), but just in case below are some links I found.

The problem at hand was that I wanted to use the functionality of a site like [Wayback/Archive] Redirect Checker | Check your Statuscode 301 vs 302, but on the client side because sometimes redirects depend on locality (for example, but not limited to, AliExpress sites).

Thinks like these fail with CSP errors like Refused to connect to 'https://t.co/Ui4Wmesq1j' because it violates the following Content Security Policy directive: "connect-src chrome://resources chrome://theme 'self'".:

var xhr = new XMLHttpRequest();
xhr.onload = function() {
  if (this.status < 400 && this.status >= 300) {
    console.log('request redirects to ' + this.getResponseHeader("Location"));
  } else {
    console.log('request does not redirect');
  }
}
xhr.open('HEAD', 'https://t.co/Ui4Wmesq1j', true);
xhr.send();

Links – many of them mentioning CORS, but few CSP:

On CSP, CORS and other documentation:

Queries:

--jeroen


[Wayback/Archive] Imprint | Redirect Checker

var xhr = new XMLHttpRequest();
xhr.onload = function() {
if (this.status < 400 && this.status >= 300) {
console.log('request redirects to ' + this.getResponseHeader("Location"));
} else {
console.log('request does not redirect');
}
}
xhr.open('HEAD', 'https://t.co/Ui4Wmesq1j&#39;, true);
xhr.send();
view raw code.js hosted with ❤ by GitHub

 

Leave a Comment