From 42fcc22e39aa8bd884075c27f966d79f72e6deaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 7 Jun 2026 23:36:37 +0200 Subject: [PATCH] fix(import): raise the middleware body cap so large Apple Health exports import Next 16 truncated any request body over ~10MB passing through middleware (src/proxy.ts) before the route handler saw it, so a multi-MB export.zip lost its ZIP end-of-central-directory and failed to parse (GitHub #281). Set middlewareClientMaxBodySize so real exports arrive intact. --- next.config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/next.config.ts b/next.config.ts index 7440d153a..4cef1bf1c 100644 --- a/next.config.ts +++ b/next.config.ts @@ -157,8 +157,18 @@ const nextConfig: NextConfig = { outputFileTracingExcludes: { "*": ["./next.config.ts"], }, + // Next 16 caps the request body that passes THROUGH middleware (our + // `src/proxy.ts`) at ~10MB by default, silently truncating larger bodies + // before the route handler sees them. The Apple Health `export.zip` importer + // (`/api/import/apple-health-export`) streams multi-MB archives to disk; the + // 10MB cap truncated them so the ZIP end-of-central-directory was lost and + // the parser failed (GitHub #281). Raise the ceiling so real exports pass + // intact. The value is a ceiling, not a buffer — only the actual upload size + // is held — so this is safe; very large exports also want a matching + // reverse-proxy body limit (see docs/self-hosting/reverse-proxy.md). experimental: { optimizePackageImports: ["recharts", "lucide-react"], + middlewareClientMaxBodySize: "512mb", }, };