fix(deploy): add rate limiting to Vercel deploy endpoint to match Netlify route - #519
fix(deploy): add rate limiting to Vercel deploy endpoint to match Netlify route#519Xenon010101 wants to merge 1 commit into
Conversation
The Netlify deploy endpoint enforces a per-user rate limit of 5
deploys per minute, but the Vercel endpoint had none. Both make
external API calls using shared credentials, so the Vercel route
was vulnerable to abuse that could exhaust the account quota.
Add the same rateLimit() call used in the Netlify route, keyed
on deploy-vercel:{userId}.
Closes piyushdotcomm#517
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
👋 Thanks for opening a PR, @Xenon010101!Your PR has entered the 🚦 PR Review Pipeline.
What happens next
A pipeline status comment will appear below and update automatically as your PR progresses. While you wait
This comment is posted only once. |
PR Summary by QodoAdd per-user rate limiting to Vercel deploy API endpoint
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
What changed
Added per-user rate limiting to the Vercel deploy endpoint, matching the existing rate limit on the Netlify deploy endpoint.
Closes #517
Why
The Netlify deploy route (
app/api/deploy/netlify/route.tsline 14) enforcesrateLimit(deploy-netlify:..., 5, 60_000)— max 5 deploys per minute per user. The Vercel deploy route (app/api/deploy/vercel/route.ts) has no rate limiting at all. Both endpoints make external API calls using shared credentials (theVERCEL_MASTER_TOKENfallback), so a single user or bot could send unlimited deploy requests and exhaust the Vercel account's deployment quota.Fix
Added
import { rateLimit } from "@/lib/api-utils"and the samerateLimit()call pattern used in the Netlify route. Also tightened the auth check fromsession?.usertosession?.user?.idto match the Netlify route's guard, since the rate limit key requires a user ID.Verification
npm run lint— 0 errorsnpm test— 112/112 tests passnpm run build— builds successfully