Token from Cookies server (angular to laravel)
-
After a request for authorization, the server will re-examine the "/" app and transmit to Cookie XSRF-TOKEN and laravel-session.
Objective: To submit this to each subsequent request Token Total 'Params'Having it from Cookie
How do I do it?
There's a cycle, for example:
app.controller('myCtrl', ['$http', '$scope', '$cookies', function($http, $scope, $state, $cookies) {
$http({
method:'POST',
url:'https://mysite/api/acc_details',
params: {
'token': $cookies.csrftoken}
})
Sold and "config: $http.defaults.headers.post['X-CSRFToken'] = $cookies.get('csrftoken')♪
But in that case, the server will have a headline that he should count.
and the $cookies.ge() always in the console makes a mistake that 'get' is not defined.
-
For ANgular 2.0+: https://angular.io/docs/ts/latest/guide/security.html We're adding to the module's boot.
{ provide: XSRFStrategy, useValue: new CookieXSRFStrategy('myCookieName', 'My-Header-Name')}