Skip to content

Commit d4349f8

Browse files
Copilotmrlubos
andcommitted
Clarify comment about FormData Content-Type handling
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
1 parent edf4322 commit d4349f8

File tree

1 file changed

+6
-4
lines changed
  • packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle

1 file changed

+6
-4
lines changed

packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,12 @@ export const createClient = (config: Config = {}): Client => {
139139
opts.signal = (request as any).signal as AbortSignal | undefined;
140140

141141
// When body is FormData, remove Content-Type header to avoid boundary mismatch.
142-
// The Request constructor auto-generates a boundary and sets Content-Type, but
143-
// we pass the original FormData to ofetch which will generate its own boundary.
144-
// If we keep the Request's Content-Type, the boundary in the header won't match
145-
// the boundary in the actual request body sent by ofetch.
142+
// Note: We already delete Content-Type in resolveOptions for FormData, but the
143+
// Request constructor (line 175) re-adds it with an auto-generated boundary.
144+
// Since we pass the original FormData (not the Request's body) to ofetch, and
145+
// ofetch will generate its own boundary, we must remove the Request's Content-Type
146+
// to let ofetch set the correct one. Otherwise the boundary in the header won't
147+
// match the boundary in the actual multipart body sent by ofetch.
146148
if (typeof FormData !== 'undefined' && body instanceof FormData) {
147149
opts.headers.delete('Content-Type');
148150
}

0 commit comments

Comments
 (0)