Repository navigation
v2.0.7
fix: prevent config spread from overriding merged headers
Fixed a critical bug where DEFAULT_HEADERS (Content-Type: application/json)
were being stripped from requests.
Problem
The spread operator ...config at the end of fetchConfig construction was
overriding the carefully merged headers. Since config contained headers from
state.config (an empty Headers object for new instances), it would replace
our merged headers with an empty object.
Solution
Moved the ...config spread to the beginning of the fetchConfig object,
then explicitly override with our processed values (method, headers, body, timeout).
This ensures our merged headers always take precedence.
Testing
Verified with httpbin.org:
- ✅ JSON POST requests now correctly have Content-Type: application/json
- ✅ FormData requests still correctly have multipart/form-data with boundary
- ✅ All other request types working as expected
Impact
- Fixes JSON API calls not working correctly due to missing Content-Type
- Maintains FormData/URLSearchParams behavior (skips JSON headers)
- No breaking changes to API surface