-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Following redirects discards set cookies without explicit domain #1760
Comments
Thanks @wilsonjackson - PR welcome to fix? |
@titanism Super happy to submit a fix, but I might need a little guidance.
Should it call btw failing test added here #1761 |
I'm not sure - haven't looked at that internal code in a long time. Not too much time right now other than maintenance and PR reviews. |
I'll take a stab and let you review, then. |
v8.0.9 released to npm and GitHub releases |
Describe the bug
Node.js version: 16.16.0
OS version: macOS monterey
Description: When redirects are followed (via
.redirects()
) cookies set by the redirecting server are not persisted correctly.This bug was introduced with #1757, which assumes that there will always be a
request
object set on the response received byAgent.prototype._saveCookies
. However,_saveCookies
is invoked by two events:response
andredirect
, and that assumption is only true of theresponse
event.Actual behavior
If a cookie without an explicit domain has already been set in Superagent's cookie jar, that cookie cannot be overwritten using the same parameters during a followed redirect.
Expected behavior
Setting a cookie with the same parameters in a followed redirect should overwrite the previous cookie.
Code to reproduce
https://gist.github.com/wilsonjackson/746aee8f563e8486fa2f99c32baba235
Checklist
The text was updated successfully, but these errors were encountered: