我在使用这个库时遇到了问题。客户端上使用的代码与服务器上运行的代码相同。令牌的生命周期为 1440 分钟,但此配置仅适用于本地服务器,不适用于远程服务器。
我不知道我是否应该在 apache 或系统中配置其他东西,但在 Laravel 中完全相同(我使用 git 发送更改)。在双方我都使用 Ubuntu 16.04,在我的本地服务器上我使用 php 7.1,在我的远程服务器上我使用 php 7.0。在我的本地浏览器中,我使用的是 Angular 4。我在 Laravel 中的代码是:
/*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour
|
*/
'ttl' => 1440,
/*
|--------------------------------------------------------------------------
| Refresh time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate.
| Defaults to 2 weeks
|
*/