Skip to content
Discussion options

You must be logged in to vote

Rate Limiting with Lucia

Use two layers:

  • Caddy: Global DDoS protection
  • Next.js: Auth-specific (5 attempts/min)

Example:

const limiter = new Ratelimit({
  redis: Redis.fromEnv(),
  limiter: Ratelimit.slidingWindow(5, "1 m"),
});

const { success } = await limiter.limit(ip);
if (!success) return new Response("Too many attempts", { status: 429 });

Answers:

  1. Auth needs separate stricter limit - YES
  2. Caddy + Next.js together - YES
  3. Normal pages rate limit - OPTIONAL
  4. Rate limit by route pattern, not all chunks

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zeronumbers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants