import { Injectable } from "@nestjs/common"; import { ThrottlerGuard } from "@nestjs/throttler"; @Injectable() export class AuthThrottleGuard extends ThrottlerGuard { protected async getTracker(req: Record): Promise { // Track by IP address for failed login attempts const ip = req.headers["x-forwarded-for"]?.split(",")[0]?.trim() || req.headers["x-real-ip"] || req.connection?.remoteAddress || req.socket?.remoteAddress || req.ip || "unknown"; return `auth_${ip}`; } }