Skip to content

Commit 1585e1d

Browse files
silverbackdanzoey-kaiserphoenix-ru
authored
Include cookie headers on session fetch (#971)
Co-authored-by: Zoey <zoeykaiser8@gmail.com> Co-authored-by: Marsel Shaikhin <18054980+phoenix-ru@users.noreply.github.com>
1 parent d350022 commit 1585e1d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/runtime/composables/local/useAuth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { formatToken } from './utils/token'
1010
import { useAuthState } from './useAuthState'
1111
// @ts-expect-error - #auth not defined
1212
import type { SessionData } from '#auth'
13-
import { navigateTo, nextTick, useNuxtApp, useRoute, useRuntimeConfig } from '#imports'
13+
import { navigateTo, nextTick, useNuxtApp, useRequestHeaders, useRoute, useRuntimeConfig } from '#imports'
1414

1515
interface Credentials extends Record<string, any> {
1616
username?: string
@@ -180,7 +180,10 @@ export function useAuth(): UseAuthReturn {
180180
return
181181
}
182182

183-
const headers = new Headers(tokenValue ? { [config.token.headerName]: tokenValue } as HeadersInit : undefined)
183+
const headers = new Headers(useRequestHeaders(['cookie']))
184+
if (tokenValue) {
185+
headers.append(config.token.headerName, tokenValue)
186+
}
184187

185188
loading.value = true
186189
try {

0 commit comments

Comments
 (0)