Skip to content

Conversation

@neel3o115
Copy link

@neel3o115 neel3o115 commented Nov 18, 2025

This PR fixes a long-standing issue where axios.postForm, axios.putForm, and axios.patchForm fail on React Native Android with a Network Error.
The issue occurs because Axios forces a bare:
Content-Type: multipart/form-data
header without a boundary.
React Native Android requires a boundary (e.g. boundary=----RNFormBoundaryABC123).
When Axios overrides the header, React Native cannot append the boundary, causing the request to be malformed and immediately rejected.

iOS is more permissive, so it does not fail.

What This PR Changes:-

  1. Removes the forced 'Content-Type': 'multipart/form-data' header
  2. Preserves user-provided headers
  3. Does not affect existing behavior on:

iOS React Native (already worked)

Standard axios.post / axios.patch / axios.put (not using FormData helpers)

Technical Summary

Before (broken on Android):
headers: { 'Content-Type': 'multipart/form-data' }

After (correct):
headers: isForm ? (config?.headers || {}) : {}

This lets React Native generate:
Content-Type: multipart/form-data; boundary=----RNGeneratedBoundary123
which Android accepts.

Result:-

  • Android multipart uploads work
  • No more Network Error
  • No breaking changes
  • Fully backward-compatible

Fixes
#6968

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr::fix PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants