-
-
Notifications
You must be signed in to change notification settings - Fork 604
Axios FormData upload broken in v2 #1835
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingscope:nodeRelated to MSW running in NodeRelated to MSW running in Node
Description
Prerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- I'm using the latest
mswversion - I'm using Node.js version 18 or higher
Node.js version
v18.18.2
Reproduction repository
https://github.com/pschyma/msw-examples/tree/axios-formdata-reproducer
Reproduction steps
cd examples/with-vitest
npm install
npm test
Current behavior
I'm not sure where the issue is, but as msw v2 triggered this issue for me, I'll start here.
After updating to msw 2 FormData upload via Axios stops working due to missing boundary in Content-Type header.
Headers observed when posting data with fetch:
{
'content-type' => {
name: 'content-type',
value: 'multipart/form-data; boundary=----formdata-undici-088515513855'
}
}
Headers observed when posting data with Axios:
{
'content-type' => {
name: 'content-type',
value: 'multipart/form-data'
}
}
Expected behavior
Axios requests behave like when msw < 2 is used and provide the boundary in headers.
In previous msw version, I used parse-multipart-data to extract the boundary from request headers and for parsing the text content of that request.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingscope:nodeRelated to MSW running in NodeRelated to MSW running in Node