fix(ui): useApi passes FormData through unaltered so multipart uploads work (IR/GS ingest from UI was JSON-stringifying FormData into '{}')
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,8 +24,16 @@ async function request(method, url, { body, params, signal } = {}) {
|
|||||||
const headers = {}
|
const headers = {}
|
||||||
const init = { method, headers, signal }
|
const init = { method, headers, signal }
|
||||||
if (body !== undefined) {
|
if (body !== undefined) {
|
||||||
headers['Content-Type'] = 'application/json'
|
if (body instanceof FormData) {
|
||||||
init.body = JSON.stringify(body)
|
// Let the browser set Content-Type with the multipart boundary.
|
||||||
|
// JSON-stringifying FormData produces "{}" and the backend sees
|
||||||
|
// an empty multipart payload (this broke FC-5 IR/GS ingest from
|
||||||
|
// the UI for several releases).
|
||||||
|
init.body = body
|
||||||
|
} else {
|
||||||
|
headers['Content-Type'] = 'application/json'
|
||||||
|
init.body = JSON.stringify(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = await fetch(fullUrl, init)
|
const r = await fetch(fullUrl, init)
|
||||||
|
|||||||
Reference in New Issue
Block a user