Hello,
We were currently running into an issue, that with the new node version of 18.18.2 (where they introduced a security fix for undici) and the latest version of ky (1.1.0), headers are not properly set on the request with a json payload.
I tracked it down to this line of code:
|
this.request = new globalThis.Request(this.request, {body: this._options.body}); |
Basically, with the node version 18.18.2, as soon a new Request is being created, it loses all the options (including headers) that were set on this.request, resulting in a new Request with only content-type: text/plain;charset=UTF-8 being set. In node 18.18.1, everything is working fine
I was able to make it work by spreading out the options.
this.request = new globalThis.Request(this.request, { ...this._options, body: this._options.body });
However, it's hard for me to tell if this is actually a bug in node (undici), or if it was never supposed to work like this and they fixed it with the new version.
Hello,
We were currently running into an issue, that with the new node version of 18.18.2 (where they introduced a security fix for undici) and the latest version of
ky(1.1.0),headersare not properly set on the request with ajsonpayload.I tracked it down to this line of code:
ky/source/core/Ky.ts
Line 203 in d372e2e
Basically, with the node version 18.18.2, as soon a new Request is being created, it loses all the
options(including headers) that were set onthis.request, resulting in a new Request with onlycontent-type: text/plain;charset=UTF-8being set. In node 18.18.1, everything is working fineI was able to make it work by spreading out the options.
However, it's hard for me to tell if this is actually a bug in
node(undici), or if it was never supposed to work like this and they fixed it with the new version.