Rate Limiting — Security · NestJS

Nothing in the API stops a script from trying ten thousand passwords, or from calling one route until the database gives up. A throttler counts requests per caller and route and answers 429 past the limit, tighter on sign-in, not at all on the health check.

What you will learn

Read the theory for Rate Limiting

All Security lessons

All NestJS courses

loading types…

What you'll learn

  • Say what a rate limit defends against (credential stuffing, scraping, one client starving the rest) and what it does not (a distributed attack)
  • Configure @nestjs/throttler with a ttl and a limit, bind ThrottlerGuard globally, and read the X-RateLimit headers it adds
  • Tighten one route with @Throttle and exempt another with @SkipThrottle
  • Explain what the counter is keyed on (the caller's address and the route) and why a proxy changes that