NestJS · Senior · Question 72 of 75
How do you rate limit per authenticated user instead of per IP with @nestjs/throttler?
- 1Throttler only supports IP addresses
- ✓Correct answer: Extend
ThrottlerGuardand overridegetTracker()to return the user ID (falling back to IP for anonymous requests) - 3Add the user ID to the URL
Explanation
Many users behind one corporate NAT share an IP; per-user limits are fairer for authenticated APIs.