In the routes.php file, add
Route::get ('/api/index ', ' apicontroller@index ', [' middleware ' = ' auth ']);
But found this middleware does not work, Google a bit, the route is so written, but why I do not play a role here?
Reply content:
In the routes.php file, add
Route::get ('/api/index ', ' apicontroller@index ', [' middleware ' = ' auth ']);
But found this middleware does not work, Google a bit, the route is so written, but why I do not play a role here?
Nothing specific?
See if the $routeMiddleware array in kernel.php contains
'auth' => 'App\Http\Middleware\Authenticate',
Nathan_wu reply is correct, is my writing has a problem, the correct wording should be the following
Route::get (' Home ', [
' Middleware ' = [' auth '],//use the roles middleware
' Uses ' = ' homecontroller@index ',
]);
But originally I was a Google to a foreigner article, it is written in Jiangzi,
$router->get ("/awesome/sauce", "awesomecontroller@sauce", [' middleware ' = ' auth ']);
So just imitate his writing, the result of middleware does not work, may be laravel version of the problem it
Just solve the problem.