diff --git a/src/runtime/plugins/apollo.ts b/src/runtime/plugins/apollo.ts index d1efe41..aac360c 100644 --- a/src/runtime/plugins/apollo.ts +++ b/src/runtime/plugins/apollo.ts @@ -76,6 +76,7 @@ export default defineNuxtPlugin({ const authLink = setContext((_, { headers }) => { const { accessTokenState, refreshTokenState } = useAuthState(); let token: string; + let cookies: string = headers?.cookies ?? defaultHeaders?.cookies ?? ''; console.log(defaultHeaders, headers); @@ -87,12 +88,17 @@ export default defineNuxtPlugin({ } } + if (process.client) { + cookies = (cookies.length ? cookies + '; ' : '') + document.cookie; + } + return { headers: { ...headers, ...defaultHeaders, Authorization: token ? `Bearer ${token}` : '', // Token in header - origin: defaultHeaders?.origin ?? defaultHeaders?.referer, + cookies: cookies, + origin: headers.origin ?? defaultHeaders?.origin ?? defaultHeaders?.referer, }, }; });