While utilizing a third-party embedded code that initiates HTTP requests with a request header origin different from my own, I encountered an issue. Despite attempting to intercept these HTTP requests using XMLHttpRequest, they do not get intercepted. This could be due to the difference in origins. It is worth noting that the Chrome Developer Tools do successfully intercept these requests.
let oldXHROpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url) {
console.log(url)
return oldXHROpen.apply(this, arguments);
}
By implementing the above code snippet, only requests with a request header origin matching my domain are logged. Requests displayed in the dev-tools with a request header origin differing from my domain are not logged.