The endpoint that worked fine until it didn't
You asked Cursor to add a password reset flow. It generated the route, the email template, the Supabase call. You tested it. It worked. You deployed.
Two weeks later your SendGrid bill is 400 because someone wrote a script that hits your reset endpoint ten thousand times in an hour. The emails still send. The endpoint still returns 200. The only thing that changed is who is calling it.
This is not an edge case. It is the default for AI-generated code.
Why AI tools skip rate limiting
When you describe a feature to an AI coding assistant, you describe the happy path. The model writes code that does exactly that. It does not write code that prevents someone from calling it fifty times a second.
Rate limiting is a cross-cutting concern. The AI optimises for the feature you asked for. It does not optimise for the operational reality of a public endpoint.
The same gap appears on authentication endpoints, search endpoints, file upload endpoints, webhook receivers, any API route that calls a paid service, and any endpoint that writes to your database.
What no rate limit looks like in production
The bill shock
Your app uses OpenAI for a chat feature. No limit on requests per user. No limit on prompt length. A user sends 100,000 token prompts in a loop. Your OpenAI bill arrives at 3,000.
The database lock
A search endpoint runs a full-text search with no pagination limit. Someone sends a query that matches every row. The query runs for forty seconds. Ten parallel requests later your database CPU is at 100 percent.
The email reputation hit
The password reset endpoint sends an email on every request. No cooldown. An attacker cycles through a list of emails. Your domain gets flagged for spam.
The webhook flood
Stripe sends a checkout.session.completed event. No idempotency check. Stripe retries because your handler took too long. You process the same order five times.
The minimal rate limiting setup
You need three layers.
Layer 1: Hosting-level protection
Enable built-in DDoS and rate limiting on Vercel, Netlify, Cloudflare or AWS. They are free and stop volumetric attacks before they reach your code.
Layer 2: Framework middleware
Next.js, Astro, Express, Fastify, Hono — every modern framework has rate limiting middleware. Add it globally, then tune per route.
Layer 3: Application-level logic for paid operations
For any endpoint that calls a paid API or sends email, add a per-user quota in your application code.
How to test your own endpoints
You need curl and a loop.
Test 1: Basic rate limit with a for loop hitting your endpoint 15 times.
Test 2: Per-user quota on authenticated endpoints.
Test 3: Expensive endpoint estimation.
Test 4: Webhook idempotency.
What the free surface check sees
The free surface check at Vibe Code Guardian looks at what is publicly visible. It cannot test rate limits. That is why the launch-readiness audit includes live endpoint testing.
A checklist you can run this afternoon
List every API route.
Mark routes that call paid services, send email, write to database, or handle auth.
Ask what happens if someone calls each 100 times a minute.
Enable hosting-level rate limiting.
Add framework middleware with a generous global limit.
Add stricter per-route limits.
Add per-user quotas for paid endpoints.
Test each one with curl.
Document the limits in your README.
The pattern that prevents this problem
The root cause is not I forgot rate limiting. The root cause is I asked the AI for a feature and it gave me the happy path.
Every time you prompt for an endpoint, add: Include rate limiting, per-user daily quota for paid operations, idempotency for webhooks.
If you would rather a developer verify the whole thing, the launch-readiness audit checks 137 points across 14 areas including rate limiting.