Skip to content

Instantly share code, notes, and snippets.

@neodigm
Last active November 5, 2021 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/65bbc27ab38ae0128da04fbfd9282393 to your computer and use it in GitHub Desktop.
Save neodigm/65bbc27ab38ae0128da04fbfd9282393 to your computer and use it in GitHub Desktop.
var RealXMLHttpRequest = window.XMLHttpRequest;
window.XMLHttpRequest = function(){
var asynchrony = new RealXMLHttpRequest();
var realOpen = asynchrony.open;
// steal the OPEN method | Has to be open to send header
asynchrony.open = function(method, url){
realOpen.apply(asynchrony, arguments);
asynchrony.setRequestHeader('X-Custom', 'customtext');
};
return asynchrony;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment