I'm having trouble with POST request in Laravel 5.2.
In my routes file i'm using web middleware on every route. also in my form i have csrf_field() but when im trying to make a POST request, it gives my TokenMismatchException
GoTo : App->Http->Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
Comment the last line:
// App\Http\Middleware\VerifyCsrfToken::class,
But this solution is only for escaping from csrf token verification, not a good option to do.
There is a helper to add the form token inside forms. You can just use:
{!! csrf_field() !!}
...inside the forms. It will add the hidden input and the token.
try to add this line in the body of your html file :
<meta name="_token_" content="{{ csrf_token() }}">