From d4349f8b2ea221cb425bd2ed67822411f66db494 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:16:09 +0000 Subject: [PATCH] Clarify comment about FormData Content-Type handling Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../plugins/@hey-api/client-ofetch/bundle/client.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/client.ts index 6e647969a..3cb2c6ffc 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/client.ts @@ -139,10 +139,12 @@ export const createClient = (config: Config = {}): Client => { opts.signal = (request as any).signal as AbortSignal | undefined; // When body is FormData, remove Content-Type header to avoid boundary mismatch. - // The Request constructor auto-generates a boundary and sets Content-Type, but - // we pass the original FormData to ofetch which will generate its own boundary. - // If we keep the Request's Content-Type, the boundary in the header won't match - // the boundary in the actual request body sent by ofetch. + // Note: We already delete Content-Type in resolveOptions for FormData, but the + // Request constructor (line 175) re-adds it with an auto-generated boundary. + // Since we pass the original FormData (not the Request's body) to ofetch, and + // ofetch will generate its own boundary, we must remove the Request's Content-Type + // to let ofetch set the correct one. Otherwise the boundary in the header won't + // match the boundary in the actual multipart body sent by ofetch. if (typeof FormData !== 'undefined' && body instanceof FormData) { opts.headers.delete('Content-Type'); } -- 2.51.2