Skip to content

Commit ed9afad

Browse files
authored
fix(#922): always proxy cookies in signIn and getSession (#1067)
* fix(#922): always proxy cookies in signIn and getSession * chore: apply lint fix
1 parent a34eff1 commit ed9afad

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/runtime/composables/authjs/useAuth.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,19 @@ export function useAuth(): UseAuthReturn {
162162
json: true
163163
})
164164

165-
const fetchSignIn = () => _fetch<{ url: string }>(nuxt, `/${action}/${provider}`, {
166-
method: 'post',
167-
params: authorizationParams,
168-
headers,
169-
body
170-
}).catch<Record<string, any>>((error: { data: any }) => error.data)
165+
const fetchSignIn = () => _fetch<{ url: string }>(
166+
nuxt,
167+
`/${action}/${provider}`,
168+
{
169+
method: 'post',
170+
params: authorizationParams,
171+
headers,
172+
body
173+
},
174+
/* proxyCookies = */ true
175+
)
176+
.catch<Record<string, any>>((error: { data: any }) => error.data)
177+
171178
const data = await callWithNuxt(nuxt, fetchSignIn)
172179

173180
if (redirect || !isSupportingReturn) {
@@ -272,7 +279,7 @@ export function useAuth(): UseAuthReturn {
272279
onRequestError: onError,
273280
onResponseError: onError,
274281
headers
275-
})
282+
}, /* proxyCookies = */ true)
276283
}
277284
function getSessionWithNuxt(nuxt: NuxtApp) {
278285
return callWithNuxt(nuxt, getSession)

src/runtime/composables/local/useAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function useAuth(): UseAuthReturn {
7676
body: credentials,
7777
params: signInParams ?? {},
7878
headers: signInHeaders ?? {}
79-
})
79+
}, /* proxyCookies = */ true)
8080

8181
if (typeof response !== 'object' || response === null) {
8282
console.error(`${ERROR_PREFIX} signIn returned non-object value`)
@@ -187,7 +187,7 @@ export function useAuth(): UseAuthReturn {
187187

188188
loading.value = true
189189
try {
190-
const result = await _fetch<any>(nuxt, path, { method, headers }, true)
190+
const result = await _fetch<any>(nuxt, path, { method, headers }, /* proxyCookies = */ true)
191191
const { dataResponsePointer: sessionDataResponsePointer } = config.session
192192
data.value = jsonPointerGet<SessionData>(result, sessionDataResponsePointer)
193193
}

0 commit comments

Comments
 (0)