How does node koa-jwt Refresh Token?

learn node+koa developer is writing a simple example and using token

app.use(jwtKoa({secret}).unless({
    path: [/^\/adduser/, /^\/login/] //jwt
}))

when you log in, return to the frontend token and set it to be valid for one hour, but if the token fails, you don"t want the user to log in again to get the token, but want to refresh the token. What should I do?

jwt.sign({
    name: islogin[0].username,
    //  token 
    exp: 60 * 60, // 60 seconds * 60 minutes = 1 hour
  }, secret)
Apr.11,2021

Refresh Token is not in the category of jwt . You need to implement the logic of Refresh Token yourself. For example, when you listen to the error type expired of jwt , update token .

Menu