Illuminate \ Routing \ Router :: middleware()缺少参数2
api.php
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
RouteServiceProvider.php
protected function mapApiRoutes()
{
Route::group([
'middleware' => ['api', 'auth:api'],
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
}
答案 0 :(得分:0)
我有同样的问题。问题是直到版本5.4,您才能调用Route::middleware('auth:api')
在5.3版中,它必须称为Route::group(['middleware' => 'auth:api'], function() { ... })