Open
Description
Environment
- Operating System: Linux
- Node Version: v20.17.0
- Nuxt Version: 3.13.0
- CLI Version: 3.13.1
- Nitro Version: 2.9.7
- Package Manager: pnpm@9.0.4
- Builder: -
- User Config: -
- Runtime Modules: -
- Build Modules: -
Nuxt auth version: 9.0.1
Reproduction
With the configuration below, sign in to the app and reload the page
const determineBaseUrl = () => {
const baseUrl = process.env.NUXT_PUBLIC_BASE_API || '/api'
// Check if the baseUrl finishes with a trailing slash
return !baseUrl.endsWith('/') ? `${baseUrl}/auth/` : `${baseUrl}auth/`
}
const authOptions: ModuleOptions = {
baseURL: determineBaseUrl(),
globalAppMiddleware: true,
isEnabled: true,
provider: {
endpoints: {
getSession: { method: 'get', path: `session` },
signIn: { method: 'post', path: `credentials` },
signOut: { method: 'delete', path: `logout` },
// @ts-expect-error disable sign up, like in the example from the docs: https://auth.sidebase.io/guide/local/quick-start#api-endpoints
signUp: false,
},
pages: {
login: '/login',
},
// See: https://github.com/sidebase/nuxt-auth/issues/867#issuecomment-2293906780
refresh: {
endpoint: { method: 'post', path: `refresh-token` },
isEnabled: true,
refreshOnlyToken: true,
token: {
cookieName: 'auth.refresh',
httpOnlyCookieAttribute: false,
maxAgeInSeconds: 2592000,
refreshRequestTokenPointer: '/refreshToken',
sameSiteAttribute: 'lax',
secureCookieAttribute: false,
signInResponseRefreshTokenPointer: '/refreshToken',
},
},
session: {
dataType: {
companyHasAcceptedTermsOfUse: 'boolean',
companyId: 'number',
companyName: 'string',
email: 'string',
firstName: 'string',
fullyConnected: 'boolean',
id: 'string',
isTwoFactorInitialized: 'boolean',
lastName: 'string',
roles: '(\'admin\' | \'member\')[]',
username: 'string',
},
},
token: {
cookieName: 'auth.token',
headerName: 'Authorization',
httpOnlyCookieAttribute: false,
maxAgeInSeconds: 15 * 60, // 15 minutes
sameSiteAttribute: 'lax',
secureCookieAttribute: false,
signInResponseTokenPointer: '/accessToken',
},
type: 'local',
},
sessionRefresh: {
enableOnWindowFocus: true, // disable to avoid conflicts when switching tabs
enablePeriodically: 5 * 60 * 1000, // every 5 minutes
},
}
Describe the bug
The /refresh-token route is called a loop. The first calls refresh the token and then saturate the backend.
Cookies seems to be correctly set
Additional context
No response
Logs
No response