Refresh of Session not Working - Next.js / Serverless Deployment Model

Hi,

I followed this guide How to Authenticate with Next.js and Auth0: A Guide for Every Deployment Model and the login and signup are working fine.

However, my token is getting invalid after some time and the redirection to log in or the refresh is not working automatically and I have no idea why.

I changed the handleAuth route to add the offline_access scope to get a refresh token but the refresh is not working. I simply get a 401 with token expired.

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, {
        authorizationParams: {
          // Add the `offline_access` scope to also get a Refresh Token
          scope: 'openid profile email offline_access' // or AUTH0_SCOPE
        }
      });
    } catch (error) {
      res.status(error.status || 400).end(error.message);
    }
  }
});

Any idea how to get the refresh working automatically?

Hi, I’m having the same issue, how did you resolve this?