Skip to content

fix(fetch): remove Content-Type without boundary for FormData#7314

Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom
darwin808:fix/fetch-formdata-boundary
Apr 8, 2026
Merged

fix(fetch): remove Content-Type without boundary for FormData#7314
jasonsaayman merged 2 commits intoaxios:v1.xfrom
darwin808:fix/fetch-formdata-boundary

Conversation

@darwin808
Copy link
Copy Markdown
Contributor

Summary

  • Fixes an issue where using the fetch adapter with FormData and manually setting Content-Type: multipart/form-data would result in a missing boundary
  • The fix detects when Content-Type is set to multipart/form-data without a boundary and removes it, allowing fetch to automatically set the correct header with the proper boundary
  • Preserves Content-Type if it already includes a boundary

Test plan

  • Added test: "should remove manually set Content-Type without boundary for FormData"
  • Added test: "should preserve Content-Type if it already has boundary"
  • All existing tests pass

Fixes #7054

When using the fetch adapter with FormData and manually setting
Content-Type to 'multipart/form-data' (without boundary), the
request would fail because the boundary is required.

This fix detects when Content-Type is set to multipart/form-data
without a boundary and removes it, allowing fetch to automatically
set the correct Content-Type header with the proper boundary.

Fixes axios#7054
@jasonsaayman jasonsaayman force-pushed the fix/fetch-formdata-boundary branch from 7ef2c1b to 311e0b4 Compare April 8, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Axios fetch adapter: Missing boundary when Content-Type is set manually with FormData

2 participants