fix(nutriphi): increase body size limit to 50mb for image uploads

The NutriPhi bot was failing with 413 "request entity too large" when
analyzing images via Base64. Added configurable bodyLimit option to
shared-nestjs-setup and set NutriPhi backend to 50mb.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-02-02 16:08:14 +01:00
parent c2c80efc50
commit b404ddc9a8
3 changed files with 13 additions and 2 deletions

View file

@ -6,4 +6,5 @@ bootstrapApp(AppModule, {
serviceName: 'NutriPhi',
additionalCorsOrigins: ['http://localhost:5180', 'http://localhost:4323'],
excludeFromPrefix: [], // no exclusions
bodyLimit: '50mb', // Large limit for Base64 image uploads
});

View file

@ -13,10 +13,12 @@
},
"dependencies": {
"@nestjs/common": "^10.0.0 || ^11.0.0",
"@nestjs/core": "^10.0.0 || ^11.0.0"
"@nestjs/core": "^10.0.0 || ^11.0.0",
"express": "^4.21.0"
},
"devDependencies": {
"@manacore/shared-tsconfig": "workspace:*",
"@types/express": "^4.17.21",
"@types/node": "^22.10.2",
"typescript": "^5.0.0"
},

View file

@ -5,8 +5,9 @@
* across all backend applications.
*/
import { INestApplication, ValidationPipe, Type } from '@nestjs/common';
import { type INestApplication, ValidationPipe, type Type } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { json, urlencoded } from 'express';
/**
* Default CORS origins for local development
@ -36,6 +37,8 @@ export interface BootstrapOptions {
excludeFromPrefix?: string[];
/** HTTP methods for CORS (default: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']) */
corsMethods?: string[];
/** Body size limit for JSON/urlencoded payloads (default: '100kb'). Use '50mb' for image uploads. */
bodyLimit?: string;
}
/**
@ -111,6 +114,11 @@ export async function bootstrapApp(
): Promise<INestApplication> {
const app = await NestFactory.create(AppModule);
// Configure body size limit (important for services handling image uploads)
const bodyLimit = options.bodyLimit ?? '100kb';
app.use(json({ limit: bodyLimit }));
app.use(urlencoded({ extended: true, limit: bodyLimit }));
// Configure CORS
configureCors(app, {
additionalOrigins: options.additionalCorsOrigins,