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:
2026-05-23 23:43:44 -04:00
parent 4da8538054
commit 4ae9815d61
+8
View File
@@ -24,9 +24,17 @@ 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) {
if (body instanceof FormData) {
// 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' headers['Content-Type'] = 'application/json'
init.body = JSON.stringify(body) init.body = JSON.stringify(body)
} }
}
const r = await fetch(fullUrl, init) const r = await fetch(fullUrl, init)
const text = await r.text() const text = await r.text()