Users are currently logged out one day after signing in, due to token expiry. This experience interrupts user workflows and creates inconvenience for regular users.
What solution would you like to see?
Implement a middleware function to monitor tokens approaching expiry and proactively refresh them. Ideally, the middleware would invoke refreshTokens before tokens expire. However, calling refreshTokens in the current middleware setup is not feasible, as it depends on cookies() from next/headers, which is inaccessible in the middleware context.
Prerequisites
What is the problem you’re trying to solve?
Users are currently logged out one day after signing in, due to token expiry. This experience interrupts user workflows and creates inconvenience for regular users.
What solution would you like to see?
Implement a middleware function to monitor tokens approaching expiry and proactively refresh them. Ideally, the middleware would invoke
refreshTokens
before tokens expire. However, callingrefreshTokens
in the current middleware setup is not feasible, as it depends oncookies()
fromnext/headers
, which is inaccessible in the middleware context.