From 89478cc3375cfa126444f442fbf462103f8917e9 Mon Sep 17 00:00:00 2001 From: Yazeed Loonat Date: Wed, 20 Mar 2024 08:36:54 -0700 Subject: [PATCH] fix: possibly throttling through the proxy stuff (#3966) --- api/src/guards/throttler.guard.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/src/guards/throttler.guard.ts b/api/src/guards/throttler.guard.ts index e5530cdc4d..cc6976f791 100644 --- a/api/src/guards/throttler.guard.ts +++ b/api/src/guards/throttler.guard.ts @@ -5,7 +5,16 @@ import { ThrottlerLimitDetail } from '@nestjs/throttler/dist/throttler.guard.int @Injectable() export class ThrottleGuard extends ThrottlerGuard { protected async getTracker(req: Record): Promise { - 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; }