在app/http/Middleware/Authenticate.php中的返回参数:
public function handle($request, Closure $next, $guard = null)
{
if ($this->auth->guard($guard)->guest()) {
// return response('Unauthorized.', 401);
// 修改非授权条件下的返回格式 确保所有api接口返回格式统一
return response([
'data' => '', 'message' => 'Unauthorized.', 'status_code' => 401
], 401);
}
return $next($request);
}