Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'strategies' of undefined #1

Closed
CavalcanteLeo opened this issue Nov 26, 2020 · 3 comments
Closed

Comments

@CavalcanteLeo
Copy link

  plugins: [
    ...
    { src: 'node_modules/nuxt-auth-auto-refresh/dist/index.js', ssr: false },
  ],


  modules: [
    ['@nuxtjs/dotenv', { filename: process.env.FILENAME }],
    '@nuxtjs/axios',
    '@nuxtjs/auth',
    '@nuxtjs/pwa',
   ....
  ],

  auth: {
    strategies: {
      local: {
        scheme: 'refresh',
        refreshToken: {
          maxAge: 60 * 60,
        },
        endpoints: {
          refresh: {
            url: '/refresh-token',
            method: 'get',
            propertyName: 'jwt',
          },
          login: { url: 'login', method: 'post', propertyName: 'token' },
          user: { url: 'users/profile', method: 'get', propertyName: false },
          logout: false,
        },
        tokenName: 'authorization',
      },
    },

    redirect: {
      login: '/entrar',
      logout: '/entrar',
      callback: '/entrar',
      home: '/templates',
    },
  },

Captura de Tela 2020-11-26 às 04 21 27

@rubengees
Copy link
Member

Please add the plugin to the plugins section of nuxt-auth (see here: https://github.com/SmartsquareGmbH/nuxt-auth-auto-refresh#usage).

Also, this plugin only works with nuxt-auth-next and not the v4 version of nuxt-auth.

@rubengees
Copy link
Member

Closing for now. Please open a new issue if you have another question or problem.

@jirbel
Copy link

jirbel commented Jun 28, 2022

Already managed to fix this issue. Must change ({ $auth }: { $auth: Auth }) to (context: { $auth: Auth }) and use context.$auth instead. Dont know why is $auth undefined in time of load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants