Skip to content

Instantly share code, notes, and snippets.

@gcollazo
Created March 10, 2012 01:58
Show Gist options
  • Select an option

  • Save gcollazo/2009697 to your computer and use it in GitHub Desktop.

Select an option

Save gcollazo/2009697 to your computer and use it in GitHub Desktop.
JavaScript: CSRF Token in Backbone.js sync
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@Adrian-Cuellar

Copy link
Copy Markdown

Thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment