title: How to set X-XSRF-TOKEN in angular when doing AJAX post
body: <p>I understand cross site forgery requests, but am unsure of one thing, how to set the X-XSRF-TOKEN in angular for the cookie to match up to. I figured it would be through Angular's $http provider when making put or post requests, but when I try to do a post request I'm getting a 403 still. I am using Django for the backend so I set the $httpProviders cookie and header name.</p>
  
  <pre><code>function Config($locationProvider, $stateProvider, $urlRouterProvider, $httpProvider) {
  
      $locationProvider.html5Mode(true);
      $httpProvider.defaults.xsrfCookieName = 'csrftoken';
      $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
      $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  
  var promise = $http({
              method: method,
              url: (isApi ? Config.api_path : '/') + uri,
              'X-CSRFToken': $http.csrftoken,
              data: data || {},
              timeout: deferred.promise
          })
  </code></pre>