Rate Limiting Missing on API Routes
Your v0-generated Next.js API routes have no rate limiting, allowing unlimited requests from any client. This exposes your application to brute force attacks on authentication endpoints, API abuse that drives up database and third-party service costs, and denial-of-service scenarios.
Without rate limiting, a single malicious user can hammer your /api/auth/login endpoint thousands of times per second trying different passwords, or scrape your entire /api/users endpoint by paginating through all records at maximum speed.
Vercel's serverless functions do not include built-in per-user rate limiting, so your v0-generated routes are completely unprotected by default. You need to add application-level rate limiting using either in-memory stores for single-instance deployments or Redis-backed stores for production.
Error Messages You Might See
Common Causes
- No rate limiting library installed — v0 does not add rate limiting packages by default
- Vercel has no built-in per-route limiting — Vercel's DDoS protection does not cover per-user API abuse
- Authentication endpoints unprotected — login and registration routes accept unlimited attempts
- Third-party API calls amplified — each unthrottled request triggers external API calls, multiplying costs
- No IP tracking or fingerprinting — unable to identify and block abusive clients
How to Fix It
- Install upstash/ratelimit — run
npm install @upstash/ratelimit @upstash/redisfor serverless-compatible rate limiting - Create rate limit middleware — build a reusable rateLimit() wrapper using sliding window algorithm with Upstash Redis
- Apply to sensitive routes — wrap authentication, payment, and data-mutation endpoints with rate limiting
- Set appropriate limits — use 5 requests/minute for login, 30/minute for general API, 100/minute for read-only endpoints
- Return proper headers — include X-RateLimit-Limit, X-RateLimit-Remaining, and Retry-After headers in responses
- Add IP-based blocking — track repeat offenders and return 429 with exponential backoff requirements
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What rate limiting library works best on Vercel?
@upstash/ratelimit with @upstash/redis is purpose-built for serverless. It uses Redis for distributed state across Vercel functions.
How many requests per minute should I allow?
For login endpoints: 5-10/minute. For general API: 30-60/minute. For public read endpoints: 100-200/minute. Adjust based on legitimate usage patterns.
Can I rate limit without Redis?
For single-instance deployments, use an in-memory Map with LRU eviction. For Vercel serverless, you need Redis because each function invocation is stateless.