Skip to content

Rate Limiting API Routes

Fresh

Source: shipfa.st/docs/security/rate-limiting-api-routes

Protect your API routes from abuse using Upstash Redis rate limiting.

Procedure

Same setup as Magic Links rate limiting, but change the matcher to your API routes:

javascript
export const config = {
  matcher: ["/api/one", "/api/two"],
};

Replace /api/one and /api/two with your actual API endpoints.

INFO

Uses sliding window algorithm: 5 requests per 60 seconds per IP. See Upstash docs for customization.

See Also