AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): buffer workspace file downloads to prevent truncation (#12349)
Zamil Majdy15e3980d65d3
diff --git a/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts b/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.tsindex d1052e2d24..74f36d8d0a 100644--- a/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts+++ b/autogpt_platform/frontend/src/app/api/proxy/[...path]/route.ts@@ -57,27 +57,25 @@ async function handleWorkspaceDownload();}- // Get the content type from the backend response+ // Fully buffer the response before forwarding. Passing response.body as a+ // ReadableStream causes silent truncation in Next.js / Vercel — the last+ // ~10 KB of larger files are dropped, corrupting PNGs and truncating CSVs.+ const buffer = await response.arrayBuffer();+const contentType =response.headers.get("Content-Type") || "application/octet-stream";const contentDisposition = response.headers.get("Content-Disposition");- // Stream the response bodyconst responseHeaders: Record<string, string> = {"Content-Type": contentType,+ "Content-Length": String(buffer.byteLength),};if (contentDisposition) {responseHeaders["Content-Disposition"] = contentDisposition;}- const contentLength = response.headers.get("Content-Length");- if (contentLength) {- responseHeaders["Content-Length"] = contentLength;- }-- // Stream the response body directly instead of buffering in memory- return new NextResponse(response.body, {+ return new NextResponse(buffer, {status: 200,headers: responseHeaders,});