Skip to content

Instantly share code, notes, and snippets.

@ichiban
Last active January 4, 2016 07:58
Show Gist options
  • Save ichiban/8591759 to your computer and use it in GitHub Desktop.
Save ichiban/8591759 to your computer and use it in GitHub Desktop.
how to treat csrf-token in angular.js / rails
angular.module('app', [])
.config(['$httpProvider', function($httpProvider) {
var csrfToken = $('meta[name="csrf-token"]').attr('content');
$httpProvider.defaults.headers.common['X-CSRF-Token'] = csrfToken;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment