From 015f95aa6d225289794056eb04e4d7bd0bc92d55 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 14 Feb 2023 16:40:57 +0000 Subject: [PATCH] Quick fix to add the ability to update the app-service HTTP MB max limits. --- packages/server/src/app.ts | 10 +++++++--- packages/server/src/environment.ts | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 177393dee7..8456647722 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -27,13 +27,17 @@ const destroyable = require("server-destroy") const app = new Koa() +let mbNumber = parseInt(env.HTTP_MB_LIMIT || "10") +if (!mbNumber || isNaN(mbNumber)) { + mbNumber = 10 +} // set up top level koa middleware app.use( koaBody({ multipart: true, - formLimit: "10mb", - jsonLimit: "10mb", - textLimit: "10mb", + formLimit: `${mbNumber}mb`, + jsonLimit: `${mbNumber}mb`, + textLimit: `${mbNumber}mb`, // @ts-ignore enableTypes: ["json", "form", "text"], parsedMethods: ["POST", "PUT", "PATCH", "DELETE"], diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 6272e0e462..256d8d10c3 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -83,6 +83,7 @@ const environment = { MULTI_TENANCY: process.env.MULTI_TENANCY, ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS, SELF_HOSTED: process.env.SELF_HOSTED, + HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT, // old CLIENT_ID: process.env.CLIENT_ID, _set(key: string, value: any) {