API 接口登录认证会自动到 Web 的登录认证,怎么能将 API 的登录认证不走 Web 的守护

API接口登录认证会自动到web的登录认证,怎么能将API的登录认证不走web的守护?
如果我将config/auth.php中的Authentication Defaults 的配置改成:

'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

正阳修改后请求接口登录授权认证一切正常,如果将默认的guard 修改为 web 就不行了,错误异常日志:

local.ERROR: Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in E:\vagrant\develop\mcc\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 125 
#0 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(125): Illuminate\\Auth\\SessionGuard->__construct('web', NULL, Object(Illuminate\\Session\\Store))
#1 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(94): Illuminate\\Auth\\AuthManager->createSessionDriver('web', Array)
#2 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(68): Illuminate\\Auth\\AuthManager->resolve('web')
#3 E:\\vagrant\\develop\\mcc\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php(54): Illuminate\\Auth\\AuthManager->guard('web')

为什么会走guard('web')捏?不是很清楚求指教

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 2
ALMAS

middleware 要写成 auth:api

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!