Created
June 9, 2013 13:07
-
-
Save oniram88/5743448 to your computer and use it in GitHub Desktop.
ExtJS - Ruby on Rails - WARNING: Can't verify CSRF token authenticity
workaround to verify csrf token in every ajax request.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.Ajax.defaultHeaders = {'Accept':'application/json'}; | |
Ext.Ajax.on('beforerequest', function (o) { | |
var csrf = Ext.select("meta[name='csrf-token']").first(); | |
if (csrf) { | |
o.defaultHeaders = Ext.apply(o.defaultHeaders || {}, {'X-CSRF-Token':csrf.getAttribute('content')}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment