From f1180c2966d32f59cf5bf200d831f5f1c786d9a6 Mon Sep 17 00:00:00 2001 From: Rizky Date: Wed, 7 Feb 2024 18:28:42 +0700 Subject: [PATCH] wip fix --- app/web/src/base/load/proxy.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/web/src/base/load/proxy.ts b/app/web/src/base/load/proxy.ts index 96e2c4ff..8bdbe818 100644 --- a/app/web/src/base/load/proxy.ts +++ b/app/web/src/base/load/proxy.ts @@ -69,16 +69,24 @@ export const fetchViaProxy = async ( (Array.isArray(data) && data[0] instanceof File) ) { const target = new URL(url); + _headers["content-type"] = "multipart/form-data"; if (data instanceof File) { + const formData = new FormData(); + formData.append("file", data); const res = await fetch(target.pathname, { - body: data, + body: formData, method: "POST", headers: _headers, }); return await res.text(); } else { + const formData = new FormData(); + let idx = 1; + for (const file of data) { + formData.append("file-" + idx++, file); + } const res = await fetch(target.pathname, { - body: data[0], + body: formData, method: "POST", headers: _headers, });