Skip to content

Commit

Permalink
fix: possibly throttling through the proxy stuff (#3966)
Browse files Browse the repository at this point in the history
  • Loading branch information
YazeedLoonat committed Mar 20, 2024
1 parent fe803b5 commit 89478cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/src/guards/throttler.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ import { ThrottlerLimitDetail } from '@nestjs/throttler/dist/throttler.guard.int
@Injectable()
export class ThrottleGuard extends ThrottlerGuard {
protected async getTracker(req: Record<string, any>): Promise<string> {
console.log('7:', req.ips.length ? req.ips : req.ip);
console.log(
'forwarded for:',
req?.headers && req.headers['X-Forwarded-For'],
);
console.log('ip:', req.ips.length ? req.ips : req.ip);

if (req?.headers && req.headers['X-Forwarded-For']) {
// if we are passing through the proxy use forwarded for
return req.headers['X-Forwarded-For'];
}
return req.ips.length ? req.ips[0] : req.ip;
}

Expand Down

0 comments on commit 89478cc

Please sign in to comment.