nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
113 stars 20 forks source link

"No strategy is set!" error #111

Closed Fukao0129 closed 3 months ago

Fukao0129 commented 7 months ago

Environment

@nuxt-alt/auth 3.1.4 @nuxt-alt/http 1.7.10 node 18.18.2 npm 9.8.1 vue 3.3.8 nuxt 3.8.2

Nuxt Config

auth: {
  strategies: {
    local: {
      endpoints: {
        login: {
          baseURL: process.env.API_URL,
          url: "login",
          method: "post",
        },
        logout: {
          baseURL: process.env.API_URL,
          url: "logout",
          method: "post",
        },
        user: {
          baseURL: process.env.API_URL,
          url: "me",
          method: "get",
        },
      },
      user: {
        property: "data.attributes",
      },
      token: {
        property: "access_token",
        global: true,
        maxAge: 60 * 1,
      },
    },
  },
},

Reproduction

I can't provide a reproduction because it occurs in my localhost server.

Describe the bug

The 500 error occurs when the localhost server starts to run. a42783c2ee18df5add299e90b80c08c9

The token is a JWT token in Bearer format, and Laravel is used in the backend.

Additional context

What I tried :

strategies: {
  laravelJWT: {
    provider: 'laravel/jwt',
    url: process.env.API_URL,
  }
}

Logs

① nuxt.js?v=134c444b:97 [nuxt] error caught during app initialization Error: No strategy is set!
② auth.plugin.mjs:126 [ERROR] [AUTH] TypeError: Cannot read properties of undefined (reading 'cookie')
③ storage.mjs?v=134c444b:81  Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'pinia')
Fukao0129 commented 3 months ago

I added the "stores" to set options in nuxt.config.ts. After removing the '.nuxt' directory, I restarted the local server, and the issue was resolved.

When I try to login, other errors occurs. But this issue has been resolved, so I close it.