Menu

Next.js API Rate Limiting: Upstash’s 200 OK Timeout Trap
📰

Next.js API Rate Limiting: Upstash’s 200 OK Timeout Trap

DEV Community: serverless·Anas Sheikh·4 days ago
#j7GJ5VfV
#devtoserverless#devto#dev#ratelimit#upstash
Long article (1330 words) — no AI summary yet.
Reading 0:00
15s threshold

Sponsored by Upstash. The implementation and opinions in this article are my own.

A rate limiter is supposed to stop requests when someone goes over the limit. So the 200 OK response recorded in an earlier local test without Redis credentials caught my attention.

The notes from that earlier test also recorded x-ratelimit-limit: 0 . In that run, the endpoint was accepting requests without an effective limit. That was an exploratory observation, not the result from the final implementation.

I used Upstash Redis with its rate-limiting SDK for this Next.js example. That sent me back to the SDK's timeout behavior. Here's the small Next.js setup, what the documentation says, and the failure case I'd check before using it on a paid API.

Set Up Rate Limiting in Next.js with Upstash Redis

The live-tested demo used Next.js 16.4.6, @upstash/ratelimit 2.2.3, and @upstash/redis 1.41.1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.