Skip to content

Commit 93e63a6

Browse files
authored
fix: add set-cookie header for each set-cookie (#726)
1 parent 1a98920 commit 93e63a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/runtime/composables/authjs/useAuth.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,14 @@ const getSession: GetSessionFunc<SessionData> = async (getSessionOptions) => {
184184
// Add any new cookie to the server-side event for it to be present on the app-side after
185185
// initial load, see sidebase/nuxt-auth/issues/200 for more information.
186186
if (process.server) {
187-
const setCookieValue = response.headers.get('set-cookie')
188-
if (setCookieValue && nuxt.ssrContext) {
189-
appendHeader(nuxt.ssrContext.event, 'set-cookie', setCookieValue)
187+
const setCookieValues = response.headers.getSetCookie ? response.headers.getSetCookie() : [response.headers.get('set-cookie')]
188+
if (setCookieValues && nuxt.ssrContext) {
189+
for (const value of setCookieValues) {
190+
if (!value) {
191+
continue
192+
}
193+
appendHeader(nuxt.ssrContext.event, 'set-cookie', value)
194+
}
190195
}
191196
}
192197

0 commit comments

Comments
 (0)