【发布时间】:2016-11-19 05:50:05
【问题描述】:
我设置了新的 L5.2,更改后的路由文件如下所示:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is 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');
});
当我去邮递员发帖时:http://kumarajiva.dev/api/v1/login 我得到:TokenMismatchException in VerifyCsrfToken.php line 67
但我的内核文件看起来像这样:
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',
],
];
我没有改变任何东西。路由 'login' 位于 'api' middelware 组中(不是 VerifyCsrfToken 所在的 'web'),但令人惊讶的是我得到了上述错误。所以我想知道-wtf?怎么样?是否总是执行“网络”中间件组(针对每个请求)?
【问题讨论】:
标签: php routing laravel-5.2 csrf middleware