From 273f6752c144a3c7397656d61bacc1484e2c93a7 Mon Sep 17 00:00:00 2001 From: Marsel Shaikhin Date: Thu, 27 Nov 2025 09:47:03 +0100 Subject: [PATCH 1/2] fix(#922): always proxy cookies in signIn and getSession --- src/runtime/composables/authjs/useAuth.ts | 20 +++++++++++++------- src/runtime/composables/local/useAuth.ts | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/runtime/composables/authjs/useAuth.ts b/src/runtime/composables/authjs/useAuth.ts index 2db4ef6e..071a8c6d 100644 --- a/src/runtime/composables/authjs/useAuth.ts +++ b/src/runtime/composables/authjs/useAuth.ts @@ -162,12 +162,18 @@ export function useAuth(): UseAuthReturn { json: true }) - const fetchSignIn = () => _fetch<{ url: string }>(nuxt, `/${action}/${provider}`, { - method: 'post', - params: authorizationParams, - headers, - body - }).catch>((error: { data: any }) => error.data) + const fetchSignIn = () => _fetch<{ url: string }>( + nuxt, + `/${action}/${provider}`, + { + method: 'post', + params: authorizationParams, + headers, + body + }, + /* proxyCookies = */ true) + .catch>((error: { data: any }) => error.data) + const data = await callWithNuxt(nuxt, fetchSignIn) if (redirect || !isSupportingReturn) { @@ -272,7 +278,7 @@ export function useAuth(): UseAuthReturn { onRequestError: onError, onResponseError: onError, headers - }) + }, /* proxyCookies = */ true) } function getSessionWithNuxt(nuxt: NuxtApp) { return callWithNuxt(nuxt, getSession) diff --git a/src/runtime/composables/local/useAuth.ts b/src/runtime/composables/local/useAuth.ts index cf29bc1b..be2696c8 100644 --- a/src/runtime/composables/local/useAuth.ts +++ b/src/runtime/composables/local/useAuth.ts @@ -76,7 +76,7 @@ export function useAuth(): UseAuthReturn { body: credentials, params: signInParams ?? {}, headers: signInHeaders ?? {} - }) + }, /* proxyCookies = */ true) if (typeof response !== 'object' || response === null) { console.error(`${ERROR_PREFIX} signIn returned non-object value`) @@ -187,7 +187,7 @@ export function useAuth(): UseAuthReturn { loading.value = true try { - const result = await _fetch(nuxt, path, { method, headers }, true) + const result = await _fetch(nuxt, path, { method, headers }, /* proxyCookies = */ true) const { dataResponsePointer: sessionDataResponsePointer } = config.session data.value = jsonPointerGet(result, sessionDataResponsePointer) } From 7d00d3ec4c06071132de97b9484f3a763c4ab28c Mon Sep 17 00:00:00 2001 From: Marsel Shaikhin Date: Thu, 27 Nov 2025 10:14:28 +0100 Subject: [PATCH 2/2] chore: apply lint fix --- src/runtime/composables/authjs/useAuth.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/runtime/composables/authjs/useAuth.ts b/src/runtime/composables/authjs/useAuth.ts index 071a8c6d..97d4a98d 100644 --- a/src/runtime/composables/authjs/useAuth.ts +++ b/src/runtime/composables/authjs/useAuth.ts @@ -171,8 +171,9 @@ export function useAuth(): UseAuthReturn { headers, body }, - /* proxyCookies = */ true) - .catch>((error: { data: any }) => error.data) + /* proxyCookies = */ true + ) + .catch>((error: { data: any }) => error.data) const data = await callWithNuxt(nuxt, fetchSignIn)