Auth-module: LaravelJWT error with ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted.

Created on 18 Dec 2020  路  13Comments  路  Source: nuxt-community/auth-module

"@nuxtjs/auth-next": "5.0.0-1608280312.c5867c3"
"nuxt": "^2.14.12",

  auth: {
    strategies: {
      laravelJWT: {
        provider: 'laravel/jwt',
        url: '/api/auth',
        endpoints: {
          login: { url: '/api/auth/login', method: 'post' },
          refresh: { url: '/api/auth/refresh', method: 'post' },
          user: { url: '/api/auth/user', method: 'get' },
          logout: { url: '/api/auth/logout', method: 'post' },
        },
        token: {
          property: 'token',
          maxAge: 60 * 60,
        },
        refreshToken: {
          property: 'token',
          maxAge: 20160 * 60,
        },
        user: {
          property: 'user',
        },
      },
    },
  },
  axios: {
    proxy: true,
    credentials: true,
  },
  proxy: {
    '/api': {
      target: process.env.API_URL || process.env.APP_URL,
    },
  },
  router: {
    middleware: ['auth'],
  },
  1. When logged in, then do "logout", and refresh page got:

    ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted.
    at eval (webpack-internal:///./node_modules/@nuxtjs/auth-next/dist/runtime.mjs:798:17)

  2. clean all cookie from chrome, refresh page got same problem

    ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted.
    at eval (webpack-internal:///./node_modules/@nuxtjs/auth-next/dist/runtime.mjs:798:17)

bug need repro

Most helpful comment

Hi guys! Thank you for report. We'll take a look at this issue :)

All 13 comments

downgrade to @nuxtjs/[email protected] working fine

Same bug appeared with local stategy today, and it worked just fine before.

Looks like dev team dont need to check token and token validity for each request because i actually have many requests which is not requires any tokens

 const token = this.scheme.token.get();
      if (!isValid) {
        if (!token && this._requestHasAuthorizationHeader(config)) {
          throw new ExpiredAuthSessionError();
        }
        return config;
      }

Same bug, downgrade to "@nuxtjs/auth-next": "5.0.0-1607693598.34d83ea" fix my problem

Hi guys! Thank you for report. We'll take a look at this issue :)

The same issue!

@oommgg @dz0tto @ximzavivka @steklopod @SultonbekovSarvarbek

Hey guys! I wasn't able to reproduce the issue using auth demo code. Can someone try the latest version of v5 and see if persist? Also a repro would be really helpful. You can use this codesandbox template: https://codesandbox.io/s/nuxt-auth-demo-zi53w

Other things that can help is your auth config, the exact version you were using and steps to reproduce the error.

Thank you in advance! :)

Note: In latest version of v5 the name of laravel providers changed

  • laravel/jwt -> laravelJWT
  • laravel/sanctum -> laravelSanctum
  • laravel/passport -> laravelPassport

I'm having the same issue, too.

package.json
"dependencies": {
"@nuxtjs/auth-next": "5.0.0-1608347545.4014627",
"@nuxtjs/axios": "^5.12.4",
"@nuxtjs/dotenv": "latest",
"core-js": "^3.6.5",
"nuxt": "^2.14.6"
},

nuxt.config.js
/*
* Auth module configuration
*
See https://auth.nuxtjs.org/schemes/local.html#options
*/
auth: {
strategies: {
local: {
token: {
property: 'jwt',
type: 'Bearer'
},
user: {
property: false
},
endpoints: {
login: {
url: 'auth/local',
method: 'post'
},
user: {
autoFetch: false,
property: false,
url: 'users/me',
method: 'get'
},
logout: false
}
}
}
},

I'm trying to get nuxt/auth to work with strapi 3.4.0. This is the error I'm hitting:

ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted.
at eval (webpack-internal:///./node_modules/@nuxtjs/auth-next/dist/runtime.mjs:798:17)

@oommgg @dz0tto @ximzavivka @steklopod @SultonbekovSarvarbek

Hey guys! I wasn't able to reproduce the issue using auth demo code. Can someone try the latest version of v5 and see if persist? Also a repro would be really helpful. You can use this codesandbox template: https://codesandbox.io/s/nuxt-auth-demo-zi53w

Other things that can help is your auth config, the exact version you were using and steps to reproduce the error.

Thank you in advance! :)

Note: In latest version of v5 the name of laravel providers changed

  • laravel/jwt -> laravelJWT
  • laravel/sanctum -> laravelSanctum
  • laravel/passport -> laravelPassport

Currently having the same issue with local auth. It worked before the latest version and now it always says

ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted. at eval (webpack-internal:///./node_modules/@nuxtjs/auth-next/dist/runtime.mjs:798:17)

@oommgg @dz0tto @ximzavivka @steklopod @SultonbekovSarvarbek @greenermoose @nathanhenniges

Hey guys! Possible fix in #950. After merged, I would appreciate if someone could test and see if it solves the issue. Thank you in advance! :)

@JoaoPedroAS51 your last commit has broke USER request. After successful login it doesn't send Authorization header and cookies.

"nuxt": "^2.14.6",
"@nuxtjs/auth-next": "5.0.0-1608138130.8c7f4dc",

I have the same issue:

ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted
It happend when I use other endpoint. For example when use my register endpoint with $axios.

The nuxt config is the same of the documentation.

auth: {
    strategies: {
      local: {
        token: {
          property: 'access_token',
          type: 'Bearer',
          required: true
        },
        user: {
          property: 'data'
        },
        endpoints: {
          login: {
            url: '/login', method: 'post',
          },
          user: {
            url: '/me', method: 'post',
          },
          logout: {
            url: '/logout', method: 'post'
          }
        }
      }
    },
    redirect: {
      login: '/login',
      logout: '/',
      callback: '/login',
      home: '/'
    }
  },

For example I use this register endpoint and this function don't run. Only show the error.

this.$axios
        .$post('register', { ... })
        .then()
        .catch()

I can reproduce this in @nuxtjs/[email protected] by setting extremely short token expiration dates in the backend (in my case Python rest_framework_simplejwt), e.g. 5s/10s token/refresh token and then doing this:

  • Log in
  • Wait 10s for both tokens to expire
  • Trigger a PATCH request, e.g. by updating something

This results in

ExpiredAuthSessionError: Both token and refresh token have expired. Your request was aborted.

The auth module will correctly log out the user and redirect to the login page, but the error nevertheless lands in the console and triggers Sentry logs etc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

essamamdani picture essamamdani  路  3Comments

Amoki picture Amoki  路  3Comments

pi0 picture pi0  路  3Comments

nikkanetiya picture nikkanetiya  路  3Comments

sebmor picture sebmor  路  3Comments