Skip to content
Permalink
Browse files
fix: server side Set-Cookie always set an array. (#367)
  • Loading branch information
sullivanpt authored and pi0 committed Jun 3, 2019
1 parent 6d92eca commit 4d3feff1cd859dd6894db0bd224ae0a98f3d4cc5
Showing 1 changed file with 2 additions and 8 deletions.
@@ -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

0 comments on commit 4d3feff

Please sign in to comment.