-
Notifications
You must be signed in to change notification settings - Fork 549
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
Persist Cookies between redirects #3784
Comments
If A and B are different origins, the spec tells us to remove cookies on cross-origin redirects. |
Yep, in my case the hostname is identical, path should not matter unless the cookie was set on a specific path other than |
"Same origin" in this case requires the protocol, hostname, and port to be identical. If this is true, I need a reproducible sample. |
They are identical, our website is behind login. That using Times like these node.js feels a bit imature compared to many of the older web backends. |
I may have been concentrating on your same origin comment too much since we've had similar reports in the past - undici does not implement a cookie jar. import { once } from 'node:events'
import { createServer } from 'node:http'
const server = createServer((req, res) => {
if (req.url === '/path1') {
res.writeHead(302, undefined, {
location: '/path2',
'set-cookie': 'a=b'
})
res.end()
} else {
console.log('ok')
console.log(req.headers)
res.end()
}
}).listen(0)
await once(server, 'listening')
const v = await fetch(`http://localhost:${server.address().port}/path1`)
console.log(v.headers.getSetCookie()) // empty |
We have an Api that you need to call on endpoint A, it sets cookies and redirects to B (and you cannot call B directly) but undici looses the cookies so the Api call fails.
(Update: both A and B live on the same origins but diffent paths and the cookie path is set on
/
)I also considered:
However on Win11 I want to use SSL certs which is poorly implemented in windows so I have to use this syntax:
But trying to wrap that with
fetchCookie
like:const fetch = fetchCookie(uWinCaFetch);
only becomes:Additional context
The text was updated successfully, but these errors were encountered: