Skip to content

Commit

Permalink
fix: server side Set-Cookie always set an array. (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpt authored and pi0 committed Jun 3, 2019
1 parent 6d92eca commit 4d3feff
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/core/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,8 @@ export default class Storage {
document.cookie = serializedCookie
} else if (process.server && this.ctx.res) {
// Send Set-Cookie header from server side
const prev = this.ctx.res.getHeader('Set-Cookie')
let value = serializedCookie
if (prev) {
value = Array.isArray(prev)
? prev.concat(serializedCookie)
: [prev, serializedCookie]
}
this.ctx.res.setHeader('Set-Cookie', value)
const prevCookies = this.ctx.res.getHeader('Set-Cookie')
this.ctx.res.setHeader('Set-Cookie', [].concat(prevCookies, serializeCookie))
}

return value
Expand Down

0 comments on commit 4d3feff

Please sign in to comment.