Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: server side Set-Cookie always set an array. #367

Merged
merged 2 commits into from
Jun 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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