sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API
MIT License
11.91k stars 342 forks source link

1.1.1 breaks multipart form boundary #539

Closed etfz closed 8 months ago

etfz commented 8 months ago

Multipart boundary value in Content-Type header does not match that of the body. Works in 1.1.0.

let formData = new FormData()
formData.append('name', '5')
return ky.post(`/api/user`, {
    body: formData,
})
POST /api/user HTTP/2
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0
Content-Type: multipart/form-data; boundary=---------------------------1565952755359404003007232716
Content-Length: 174

-----------------------------350127340439298904923059468489
Content-Disposition: form-data; name="name"

5
-----------------------------350127340439298904923059468489--
sindresorhus commented 8 months ago

// @kdelmonte

kdelmonte commented 8 months ago

I'll take a look.

spaceemotion commented 8 months ago

Came across the same issue when a user reported file uploads no longer working in Firefox (which is via S3). Chrome still works however (and all other Chromium alternatives).

sholladay commented 8 months ago

So this issue only happens on non-Chromium?

We have a test for this that is currently passing.

At the moment, our browser tests only run against Chromium. However, we have the ability to test other browsers as well. We should probably add Firefox here. Just need to replace playwright-chromium with playwright and then import { firefox } from 'playwright'.

kdelmonte commented 8 months ago

Thanks for the guidance @sholladay. I can confirm this test indeed fails along with 4 others when using import { firefox } from 'playwright'.

image

This test passes in 1.1.0 although I did find that some others do not:

image

I am investigating now.

sindresorhus commented 8 months ago

https://github.com/sindresorhus/ky/releases/tag/v1.1.2