{
"name": "server",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development nest start --watch",
"start": "cross-env NODE_ENV=production nest start",
"build": "nest build",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
},
"dependencies": {
"@nestjs/common": "^10.4.15",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.15",
"@nestjs/platform-express": "^10.4.15",
"@nestjs/throttler": "^6.3.0"
},
"devDependencies": {
"@nestjs/cli": "^10.4.9",
"@nestjs/schematics": "^10.2.3",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/express": "^5.0.0",
"@types/node": "^20",
"cross-env": "^7.0.3",
"ts-node": "^10.9.2",
"typescript": "5.5.4"
}
}
#Unknown error
9 messages · Page 1 of 1 (latest)
Package json ^^^
import { ExceptionFilter } from 'src/globals/filters/exception.filter';
import { ThrottlerBehindProxyGuard } from 'src/globals/guards/throttler-behind-proxy.guard';
import { UsersModule } from 'src/modules/users/users.module';
import { Module } from '@nestjs/common';
import { APP_FILTER, APP_GUARD } from '@nestjs/core';
@Module({
imports: [UsersModule],
providers: [
{
provide: APP_GUARD,
useClass: ThrottlerBehindProxyGuard
},
{
provide: APP_FILTER,
useClass: ExceptionFilter
}
]
})
export class AppModule {}
app.module.ts ^^^
Structure ^
{
provide: APP_GUARD,
useClass: ThrottlerBehindProxyGuard
},
When I remove this, everything works ^
import { RateLimitException } from '../exceptions/impl/rate-limit.exception';
import { Injectable } from '@nestjs/common';
import { ThrottlerGuard } from '@nestjs/throttler';
@Injectable()
export class ThrottlerBehindProxyGuard extends ThrottlerGuard {
protected getTracker(req: Record<string, any>) {
return (
req.headers['cf-connecting-ip'] ??
req.headers['x-forwarded-for'] ??
req.ip
);
}
protected throwThrottlingException(): Promise<void> {
throw new RateLimitException();
}
}
This is my code for it lol