From 925ecc17a10e6fc80b89f6eb440eb915c07b3e55 Mon Sep 17 00:00:00 2001 From: phact Date: Mon, 11 Aug 2025 16:44:58 -0400 Subject: [PATCH] upload bug fix --- frontend/src/app/api/[...path]/route.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/api/[...path]/route.ts b/frontend/src/app/api/[...path]/route.ts index a5dcc779..ba7c7134 100644 --- a/frontend/src/app/api/[...path]/route.ts +++ b/frontend/src/app/api/[...path]/route.ts @@ -45,9 +45,19 @@ async function proxyRequest( const backendUrl = `http://${backendHost}:8000/${path}${searchParams ? `?${searchParams}` : ''}`; try { - const body = request.method !== 'GET' && request.method !== 'HEAD' - ? await request.text() - : undefined; + let body: string | ArrayBuffer | undefined = undefined; + + if (request.method !== 'GET' && request.method !== 'HEAD') { + const contentType = request.headers.get('content-type') || ''; + + // For file uploads (multipart/form-data), preserve binary data + if (contentType.includes('multipart/form-data')) { + body = await request.arrayBuffer(); + } else { + // For JSON and other text-based content, use text + body = await request.text(); + } + } const headers = new Headers();