You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code is as follows,The first time I set cookie, it can be added to the request header correctly.But the second time I set cookie, it was not added to the request header.
I briefly checked this problem, It's because my server returned the set-cookie response header. Then the second request will only bring the cookie returned by the first request, but not the cookie I set.like this
Cookie: token=xxx
I hope that both the cookies returned by the first request and the cookies I set are added to the response headers correctly. like this
hasOwn(this._header, 'cookie') return false, because of my set('Cookie',[xxx]) it will be added as header['Cookie']=[xxx],instead of header['cookie']=xxx
If I write like this, it will add the cookie to the header correctly
Describe the bug
Node.js version:
v16.20.2
OS version:
macOS 14.2.1
Description:
I use
set('Cookie',[xxx])
, but the cookie was not added to the request headerActual behavior
Cookie is not added to the request header
Expected behavior
Cookies can be added to request headers
Code to reproduce
My code is as follows,The first time I set cookie, it can be added to the request header correctly.But the second time I set cookie, it was not added to the request header.
I briefly checked this problem, It's because my server returned the
set-cookie
response header. Then the second request will only bring the cookie returned by the first request, but not the cookie I set.like thisI hope that both the cookies returned by the first request and the cookies I set are added to the response headers correctly. like this
I checked the source code
superagent/src/node/index.js
Line 856 in 1c8338b
hasOwn(this._header, 'cookie')
returnfalse
, because of myset('Cookie',[xxx])
it will be added asheader['Cookie']=[xxx]
,instead ofheader['cookie']=xxx
If I write like this, it will add the cookie to the header correctly
I don't know if this is a bug or if it's by design
Checklist
The text was updated successfully, but these errors were encountered: