Closed enzortk closed 1 month ago
I set the options in nuxt.config.ts like this
auth: { endpoints: { baseUrl: process.env.NUXT_PUBLIC_API_BASE_URL, login: { url: 'auth/login', method: 'POST', property: 'data' }, logout: { url: 'auth/logout', method: 'DELETE' }, refresh: { url: 'auth/refresh-token', method: 'POST', property: 'data' }, user: { url: 'auth/me', method: 'GET', property: 'data' }, // signup: { url: 'auth/register' }, }, middleware: { global: true }, token: { headerName: 'Authorization', type: 'Bearer', }, refreshToken: { paramName: 'token', }, },
but when I run the app, console shows this error
nuxt.js?v=a9160863:122 [nuxt] error caught during app initialization TypeError: Cannot read properties of undefined (reading 'hasTokens') at authMiddleware (auth.mjs?v=a9160863:19:28)
Seems the $auth object is undefined at that point of the code, any idea of what is wrong with the config ?
@enzortk Can you create a reproduction repo on stackblitz.com?
Ok! give me some time and I'll share the link
I set the options in nuxt.config.ts like this
but when I run the app, console shows this error
nuxt.js?v=a9160863:122 [nuxt] error caught during app initialization TypeError: Cannot read properties of undefined (reading 'hasTokens') at authMiddleware (auth.mjs?v=a9160863:19:28)
Seems the $auth object is undefined at that point of the code, any idea of what is wrong with the config ?