test: use forwarded for heder to catch real IP

This commit is contained in:
Mhd Zayd Skaff
2025-06-24 10:46:14 +03:00
parent 238a52bfa9
commit 5ad5e7e934
2 changed files with 11 additions and 2 deletions

View File

@ -35,12 +35,12 @@ import { UserNotificationModule } from './user-notification/user-notification.mo
import { UserModule } from './users/user.module';
import { VisitorPasswordModule } from './vistor-password/visitor-password.module';
import { ThrottlerGuard } from '@nestjs/throttler';
import { ThrottlerModule } from '@nestjs/throttler/dist/throttler.module';
import { winstonLoggerOptions } from '../libs/common/src/logger/services/winston.logger';
import { AqiModule } from './aqi/aqi.module';
import { OccupancyModule } from './occupancy/occupancy.module';
import { WeatherModule } from './weather/weather.module';
import { ThrottlerGuard } from '@nestjs/throttler';
@Module({
imports: [
ConfigModule.forRoot({
@ -48,6 +48,10 @@ import { ThrottlerGuard } from '@nestjs/throttler';
}),
ThrottlerModule.forRoot({
throttlers: [{ ttl: 60000, limit: 30 }],
generateKey: (context) => {
const req = context.switchToHttp().getRequest();
return req.headers['x-forwarded-for'] || req.ip;
},
}),
WinstonModule.forRoot(winstonLoggerOptions),
ClientModule,