Closed wx1860 closed 3 years ago
bootstrap/App.php
里边 AuthServiceProvider 注册了吗?
注册了,发布到tars平台第一次请求成功,第二次的时候就报错,在本地用nginx代理毫无问题
src/app/Providers/AuthServiceProvider.php
src/routes/web.php
@wx1860 没有重现
public function boot() { // Here you may define how you wish users to be authenticated for your Lumen // application. The callback which receives the incoming request instance // should return either a User instance or null. You're free to obtain // the User instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) {
//先取cookie
$jwt = Cookie::get('jwt');
if(!$jwt){
//从hearde取
$jwt = $request->header('token');
}
if($jwt){
Log::debug("Authorize:" . $jwt);
return $this->getUser($jwt);
}
});
}
对AuthServiceProvider的boot方法改了一下
public function boot() { // Here you may define how you wish users to be authenticated for your Lumen // application. The callback which receives the incoming request instance // should return either a User instance or null. You're free to obtain // the User instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) { //先取cookie $jwt = Cookie::get('jwt'); if(!$jwt){ //从hearde取 $jwt = $request->header('token'); } if($jwt){ Log::debug("Authorize:" . $jwt); return $this->getUser($jwt); } }); }
对AuthServiceProvider的boot方法改了一下
这个修改看上去与对接TarsPHP无关。 你可以用composer更新下laravel-tars,我这边没有出现你反馈的问题了。
多谢,更新到0.1.10问题解决,之前用的0.1.5版本