-
Notifications
You must be signed in to change notification settings - Fork 14
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
setCookie [SSR]: Do not override existing cookies with new one. #183
base: master
Are you sure you want to change the base?
Conversation
@pi0 any chance this will get reviewed and released? 🤔 |
Any updates? |
@farzadso is this project still being maintained? This PR is already 3m without any feedback. |
1 year passed, who cares, right? :) |
const existingCookies = this.ctx.res.getHeader('Set-Cookie') | ||
const cookies = Array.isArray(existingCookies) | ||
? [...existingCookies, serializedCookie] | ||
: [existingCookies, serializedCookie] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if existingCookies
is null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farzadso should be good now. Thanks for noticing!
As per setHeader documentation:
So, whenever
$storage.setCookie()
is called on SSR side, it replaces all cookies which were set before and it's impossible to set 2 different cookies using$storage.setCookie()
on SSR, as only the last one will get into "Set-Cookies" header.This PR aims to fix this issue.