Skip to content

Commit

Permalink
fix: SSR only keeps the last cookie set quasarframework#2547
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Sep 12, 2018
1 parent bfc54f6 commit 009455d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions dev/components/other/cookies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default {
if (this.$isServer) {
console.log('setting ssr_cookie')
this.$q.cookies.set('ssr_cookie', 'yes')
this.$q.cookies.set('ssr_cookie-second', 'yes')
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ function set (key, val, opts = {}, ssr) {
].join('')

if (ssr) {
ssr.res.setHeader('Set-Cookie', cookie)
if (ssr.req.qCookies) {
ssr.req.qCookies.push(cookie)
}
else {
ssr.req.qCookies = [ cookie ]
}

ssr.res.setHeader('Set-Cookie', ssr.req.qCookies)

// make temporary update so future get()
// within same SSR timeframe would return the set value
Expand Down

0 comments on commit 009455d

Please sign in to comment.