From c5dd5e28fd88f3026f3c59b01d8c186f118043d9 Mon Sep 17 00:00:00 2001 From: ZaydSkaff Date: Thu, 19 Jun 2025 13:54:22 +0300 Subject: [PATCH] Test/prevent server block on rate limit (#418) --- src/main.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index 33ce70a..e00dca6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import { RequestContextMiddleware } from '@app/common/middleware/request-context import { SeederService } from '@app/common/seed/services/seeder.service'; import { Logger, ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; -import { NestExpressApplication } from '@nestjs/platform-express'; import { json, urlencoded } from 'body-parser'; import rateLimit from 'express-rate-limit'; import helmet from 'helmet'; @@ -12,7 +11,7 @@ import { AppModule } from './app.module'; import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter'; async function bootstrap() { - const app = await NestFactory.create(AppModule); + const app = await NestFactory.create(AppModule); app.enableCors(); @@ -22,14 +21,11 @@ async function bootstrap() { app.useGlobalFilters(new HttpExceptionFilter()); app.use(new RequestContextMiddleware().use); - app.set('trust proxy', true); app.use( rateLimit({ - windowMs: 2 * 60 * 1000, - max: 50, - standardHeaders: true, - legacyHeaders: false, + windowMs: 5 * 60 * 1000, + max: 500, }), );