I am getting Csrf token mismatch error on every post request I am making in the project. I am using ajax at some places and normal form submission at other places. However the error is constant.
I have tried several things as suggested on this site like
- Setting
SESSION_SECURE_COOKIE=false
. - Adding
@csrf
inside<form></form>
- Adding
<meta name="csrf-token" content="{{ csrf_token() }}" />
and$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content');}});
before ajax call. - Running
php artisan config:clear
php artisan route:clear
composer dump-autoload
. - Running project on different browsers.
The error is same throughout. The application was working absolutely fine. What is the thing I am missing?