Skip to content

Instantly share code, notes, and snippets.

@dongalor
Created July 20, 2020 23:02
Show Gist options
  • Save dongalor/4513610837a9ddd47b049d8518fbd00a to your computer and use it in GitHub Desktop.
Save dongalor/4513610837a9ddd47b049d8518fbd00a to your computer and use it in GitHub Desktop.
CSRF FOR ALL THE XHR
(function() {
var send = XMLHttpRequest.prototype.send,
token = $('meta[name=csrf-token]').attr('content');
XMLHttpRequest.prototype.send = function(data) {
this.setRequestHeader('X-CSRF-Token', token);
return send.apply(this, arguments);
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment