Laravel X-CSRF-Token mismatch with POSTMAN

前端 未结 4 1033
春和景丽
春和景丽 2021-01-04 02:36

I try to talk to my REST API built with Laravel. But the call with POSTMAN is rejected due to a token mismatch. I guess I need to include the CSRF token in the header. But d

4条回答
  •  生来不讨喜
    2021-01-04 03:38

    Yes it changes every refresh. You should be putting it in the view and when you post it needs to be sent as the value of the "_token" POST var.

    If you are just using a standard POST just add this to the form:

    
    

    If you are using AJAX make sure you grab the value of _token and pass it with the request.

    REF: http://laravel.com/docs/5.1/routing#csrf-protection

提交回复
热议问题