php - Laravel5.2 Unwanted VerifyCsrfToken -
i set fresh l5.2 , route files after changes looks that:
<?php /* |-------------------------------------------------------------------------- | application routes |-------------------------------------------------------------------------- | | here can register of routes application. | it's breeze. tell laravel uris should respond | , give controller call when uri requested. | */ route::get('/', function () { return view('welcome'); }); route::group(['middleware' =>'api', 'prefix' => '/api/v1'], function () { route::post('/api/v1/login', 'api\v1\auth\authcontroller@postlogin'); });
when go postman , make post: http://kumarajiva.dev/api/v1/login get: tokenmismatchexception in verifycsrftoken.php line 67
but me kernel file looks that:
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, ], 'api' => [ 'throttle:60,1', ], ];
i don't change anything. route 'login' in 'api' middelware group (not 'web' verifycsrftoken), surprisingly above error. wonder - wtf? howi works? 'web' middelware group allways executed (for each request)?
by default, looks if routes wrapped 'web' group.
within routeserviceprovider
there function.
/** * define "web" routes application. * * these routes receive session state, csrf protection, etc. * * @param \illuminate\routing\router $router * @return void */ protected function mapwebroutes(router $router) { $router->group([ 'namespace' => $this->namespace, 'middleware' => 'web', ], function ($router) { require app_path('http/routes.php'); }); }
if want specific uri not check csrf token, go app\http\middleware\verifycsrftoken
, add uri $except
array.
you can use cli , php artisan route:list
see routes in behind middleware.
Comments
Post a Comment