Answers for "{message: "csrf token mismatch.", exception: larave"

PHP
0

message: "CSRF token mismatch."

SOLUTION: https://stackoverflow.com/questions/32738763/laravel-csrf-token-mismatch-for-ajax-post-request

The best way to solve this problem "X-CSRF-TOKEN" is to add the following code to your main layout, and continue making your ajax calls normally:

In header

<meta name="csrf-token" content="{{ csrf_token() }}" />
In script

<script type="text/javascript">
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
</script>
Posted by: Guest on December-23-2021
1

laravel-csrf-token-mismatch

<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">
Posted by: Guest on May-23-2021

Code answers related to "{message: "csrf token mismatch.", exception: larave"

Browse Popular Code Answers by Language