Laravel 5.7
PHP 7.2.10
Run Code Online (Sandbox Code Playgroud)
目前我可以使用 web 和 api 守卫中的任何一个,有什么方法可以同时使用两者,以便 web 应用程序和 api 可以一起工作。
就像是
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'api|web',
'passwords' => 'users',
],
Run Code Online (Sandbox Code Playgroud)
如果不使用架构,这是一个需要更改架构的解决方案/解决方法,这是我不喜欢的。此外,我不需要访问令牌进行注册,这个答案在做什么。
api.php
Route::group([
'middleware' => 'api|web',
'prefix' => 'auth'
], function …Run Code Online (Sandbox Code Playgroud) laravel laravel-middleware laravel-5.7 laravel-guard laravel-jwt