From 6857b4ea03f89758c9a79b19a355755f26c29daf Mon Sep 17 00:00:00 2001 From: Mhd Zayd Skaff Date: Thu, 19 Jun 2025 09:42:11 +0300 Subject: [PATCH] task: test rate limits on sever --- src/main.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index c9256ef..0a01fdd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,9 +9,10 @@ import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston'; import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils'; import { AppModule } from './app.module'; import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter'; +import { NestExpressApplication } from '@nestjs/platform-express'; async function bootstrap() { - const app = await NestFactory.create(AppModule); + const app = await NestFactory.create(AppModule); app.enableCors(); @@ -21,11 +22,12 @@ async function bootstrap() { app.useGlobalFilters(new HttpExceptionFilter()); app.use(new RequestContextMiddleware().use); + app.set('trust proxy', true); app.use( rateLimit({ - windowMs: 5 * 60 * 1000, - max: 500, + windowMs: 30 * 1000, + max: 50, standardHeaders: true, legacyHeaders: false, }), @@ -36,7 +38,7 @@ async function bootstrap() { next(); }); - app.getHttpAdapter().getInstance().set('trust proxy', 1); + // app.getHttpAdapter().getInstance().set('trust proxy', 1); app.use( helmet({