Closed ftrsoft closed 1 year ago
In my implementation, the names of cookies and strategies are hard-coded. It's for refresh strategy
I do not know, but after upgrade to nuxt 3.5.0 everything became fine. I tried to repeat it on the previous version, everything works too
Environment
Build Modules: -
Nuxt Config
auth: { strategies: { local: { scheme: 'refresh', localStorage: { prefix: 'auth.' }, token: { prefix: 'access_token.', property: 'results.access', maxAge: 60 5, global: true, }, refreshToken: { prefix: 'refresh_token.', property: 'results.refresh', data: 'refresh', maxAge: 60 60 24 15 }, user: { property: 'results.user', autoFetch: true }, endpoints: { login: {url: '/api/token/', method: 'post'}, refresh: {url: '/api/token/refresh/', method: 'post'}, user: {url: '/api/v1/user/', method: 'get'}, logout: {url: '/api/v1/user_logout/', method: 'post'} }, } }, routerStrategy: 'navigateTo', watchLoggedIn: true, globalMiddleware: true, pinia: { persist: true, }, redirectStrategy: 'query', redirect: { login: '/login', logout: '/', callback: '/', home: '/' } },
Reproduction
none links
Describe the bug
I have two pages: /login - Login page /order - page with middleware auth
When I go to the page "/order", I log in, everything is fine. But if you press F5 on the page "/order", then the page "/login" will load first, and then it will change to the correct one "/order"
I think that the middleware should read cookies and log in when the application initializes on the server side first time (SSR).
Additional context
To solve this problem, I used a server plugin that checks cookies and initializes auth if necessary: place it to /plugins/init.server.js file
Perhaps something similar can be implemented here
Logs
No response