Renew JWT token

Hello,

I have setup the JWT expiration time to 60 minutes and for most uses of my app it is more than enough. At each request to Strapi, the JWT validity is checked and if not, the user is redirected to the login page.

I am setting up an editor to write some kinds of how-tos. This kind of work could involve sessions over an hour. So the writer may be sent to the login page in the middle of his writing, which could be bothering at the least. Works can be lost in the process.

Would there be a solution to renew the JWT token automatically just for this part? Would you think of another way around this issue?

Thanks,
Nicolas


1 Like

What you need is called jwt sliding expiration, basically you achieve this by requesting a new jwt in the middle of the expiration period.

Hey @SorinGFS,

thanks for your answer. I think that Strapi does not propose this feature yet. I found a discussion here that may help to implement it as an extension.

Regards

Most likely Strapi won’t propose this feature in the future either, because there are plenty of authentication / authorization providers and I can’t imagine a plugin compatible with all of them. For this reason I created my Strapi Access Proxy project which uses jwt sliding expiration as default. You may want to explore it to see how it works, and maybe you’ll find a solution for your project.