From d9a28166df7b9e8a747766bd0da332a061fc655a Mon Sep 17 00:00:00 2001 From: Roman Petriv Date: Wed, 27 Mar 2024 17:37:57 +0200 Subject: [PATCH] feat: increase request body size limit --- packages/api/src/main.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/api/src/main.ts b/packages/api/src/main.ts index 49246daeb9..68d64832cb 100644 --- a/packages/api/src/main.ts +++ b/packages/api/src/main.ts @@ -2,11 +2,14 @@ import helmet from "helmet"; import { NestFactory } from "@nestjs/core"; import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger"; import { ConfigService } from "@nestjs/config"; +import { NestExpressApplication } from "@nestjs/platform-express"; import { configureApp } from "./configureApp"; import { getLogger } from "./logger"; import { AppModule } from "./app.module"; import { AppMetricsModule } from "./appMetrics.module"; +const BODY_PARSER_SIZE_LIMIT = "10mb"; + async function bootstrap() { const logger = getLogger(process.env.NODE_ENV, process.env.LOG_LEVEL); @@ -15,8 +18,9 @@ async function bootstrap() { process.exit(1); }); - const app = await NestFactory.create(AppModule, { + const app = await NestFactory.create(AppModule, { logger, + rawBody: true, }); const configService = app.get(ConfigService); const metricsApp = await NestFactory.create(AppMetricsModule); @@ -32,6 +36,8 @@ async function bootstrap() { SwaggerModule.setup("docs", app, document); } + app.useBodyParser("json", { limit: BODY_PARSER_SIZE_LIMIT }); + app.useBodyParser("urlencoded", { limit: BODY_PARSER_SIZE_LIMIT, extended: true }); app.enableCors(); app.use(helmet()); configureApp(app);