@frontera-sdk/core 1.50.54 → 1.50.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/transport.ts +16 -2
package/package.json
CHANGED
package/src/transport.ts
CHANGED
|
@@ -175,12 +175,26 @@ export async function httpRequest<T>(
|
|
|
175
175
|
...authHeaders(config),
|
|
176
176
|
accept: 'application/json',
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
// FormData carries its own multipart content type WITH a boundary, which only
|
|
179
|
+
// it can generate — setting one here, or stringifying it, produces a body the
|
|
180
|
+
// server cannot parse. `httpRequestRaw` has always known this; `httpRequest`
|
|
181
|
+
// did not, so an upload through the ergonomic path serialised to `{}` and the
|
|
182
|
+
// server saw no file at all.
|
|
183
|
+
const isFormData = typeof FormData !== 'undefined' && options.body instanceof FormData
|
|
184
|
+
if (options.body !== undefined && !isFormData) headers['content-type'] = 'application/json'
|
|
179
185
|
|
|
180
186
|
const response = await fetchImpl(buildUrl(config, path, options.query), {
|
|
181
187
|
method: options.method ?? 'GET',
|
|
182
188
|
headers,
|
|
183
|
-
body:
|
|
189
|
+
body:
|
|
190
|
+
options.body === undefined
|
|
191
|
+
? undefined
|
|
192
|
+
: isFormData
|
|
193
|
+
? // `FormData`, not `BodyInit`: the guard above narrowed it to exactly
|
|
194
|
+
// that, and `BodyInit` is a DOM-lib global the CLI's tsconfig does
|
|
195
|
+
// not load — naming it here fails that package's typecheck.
|
|
196
|
+
(options.body as FormData)
|
|
197
|
+
: JSON.stringify(options.body),
|
|
184
198
|
signal: options.signal,
|
|
185
199
|
})
|
|
186
200
|
|