Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat(backend): add `getTracker` method for IP extraction (#3535)

Raphael Hehlcb52a582acbb
diff --git a/packages/hoppscotch-backend/src/guards/gql-throttler.guard.ts b/packages/hoppscotch-backend/src/guards/gql-throttler.guard.ts
index 143165866..b51db4c96 100644
--- a/packages/hoppscotch-backend/src/guards/gql-throttler.guard.ts
+++ b/packages/hoppscotch-backend/src/guards/gql-throttler.guard.ts
@@ -9,4 +9,7 @@ export class GqlThrottlerGuard extends ThrottlerGuard {
const ctx = gqlCtx.getContext();
return { req: ctx.req, res: ctx.res };
}
+ protected async getTracker(req: Record<string, any>): Promise<string> {
+ return req.ips.length ? req.ips[0] : req.ip; // individualize IP extraction to meet your own needs
+ }
}