vendredi 25 novembre 2016

Laravel 5: 404 When Adding X-CSRF-TOKEN In Ajax

When calling Route URL from Ajax without _token or X-CSRF-TOKEN in header. I am getting TokenMismatchException in VerifyCsrfToken.php line 68 exception. But as I add _token or X-CSRF-TOKEN I am getting 404 response from the server.

$.ajax({
       url:  '/user_roles_store',
       type: "POST",
       headers : { 'X-CSRF-TOKEN' : $('#token').val() },
       dataType : 'JSON',
       data : mJson,

       success: function (data) {

       }
  });

In debugger tools under the network tab. This is making the wrong call. As shown in image. But when I remove _token or X-CSRF-TOKEN from code, it make request to provided url but now I got TokenMismatchException exception.

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire