At the end of this tutorial, you’ll have a rate limit to protect your API from abuses and attacks.
Rate limiting is a critical technique to ensure the stability and performance of your system. By controlling the number of requests a user or client can make within a given time frame, you protect your API from overuse, abuse, or even potential attacks, like DDoS.
TurboStack uses Upstash packages to apply rate limiting into our application.
UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
into your .env.local
file.TurboStack have an util function called ratelimit
, resided at apps/web/lib/upstash/ratelimit.ts
.
To apply a certain ratelimit into an API Route, you can do as the following example:
At the end of this tutorial, you’ll have a rate limit to protect your API from abuses and attacks.
Rate limiting is a critical technique to ensure the stability and performance of your system. By controlling the number of requests a user or client can make within a given time frame, you protect your API from overuse, abuse, or even potential attacks, like DDoS.
TurboStack uses Upstash packages to apply rate limiting into our application.
UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
into your .env.local
file.TurboStack have an util function called ratelimit
, resided at apps/web/lib/upstash/ratelimit.ts
.
To apply a certain ratelimit into an API Route, you can do as the following example: