Skip to content

Commit

Permalink
fix: set-cookie should not override existing cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
misterpekert committed May 25, 2021
1 parent f281615 commit 28c1ad1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/runtime/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ export class Storage implements NuxtStorage {
document.cookie = serializedCookie
} else if (process.server && this.ctx.res) {
// Send Set-Cookie header from server side
this.ctx.res.setHeader('Set-Cookie', [serializedCookie])
const existingCookies = this.ctx.res.getHeader('Set-Cookie')
const cookies = Array.isArray(existingCookies)
? [...existingCookies, serializedCookie]
: [existingCookies, serializedCookie]
this.ctx.res.setHeader('Set-Cookie', cookies)
}

return value
Expand Down

0 comments on commit 28c1ad1

Please sign in to comment.