在我的app.module中,我将JWT注册为:
JwtModule.register({
secret: `${process.env.JWT_SECRET}`,
signOptions: {
expiresIn: "24h" ,
notBefore: Math.floor(new Date().getTime() / 1000) ,
},
字符串
但当我解码令牌时,我得到这些时间戳:
iat: 1699944419,
nbf: 3399888838,
exp: 1700030819
型
nbf times显示错误的日期时间(2077年9月26日星期日下午5:03:58)
1条答案
按热度按时间5jdjgkvh1#
jsonwebtoken的
notBefore
字段似乎是相对于当前时间的时间。如果您传递一个数值,(你这样做了),该值将被视为秒,这就是为什么你在此刻加倍时间。You can see here,nbf
被分配the current timestamp plus thenotBefore
option,这导致了加倍的时间。给予一个相对于电流的时间,而不是绝对时间。