CSRF token mismatch in post request in 3.6 version

后端 未结 4 742
别那么骄傲
别那么骄傲 2020-12-10 19:19

I have two different apps of cakephp. One has a version 3.5 and other 3.6.

When i used and built 3.5 app i did not have a problem of CSRF matching in post requ

4条回答
  •  一整个雨季
    2020-12-10 19:42

    Add this code on your $.ajax() function call:

    beforeSend: function (xhr) { // Add this line
            xhr.setRequestHeader('X-CSRF-Token', $('[name="_csrfToken"]').val());
     },  // Add this line
    

提交回复
热议问题