The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Use generic rate limit error message to avoid exposing policy details
Kiran Kc0b1e1f02e6c
diff --git a/apps/web/lib/upstash/assert-rate-limit.ts b/apps/web/lib/upstash/assert-rate-limit.tsindex 925e4ae1de..2eddfd4388 100644--- a/apps/web/lib/upstash/assert-rate-limit.ts+++ b/apps/web/lib/upstash/assert-rate-limit.ts@@ -23,24 +23,6 @@ export const formatRetryAfter = (resetAt: number) => {return `${hours} ${pluralize("hour", hours)}`;};-// Formats a ratelimit window as a human-friendly duration-const formatWindow = (window: RatelimitPolicy["window"]) => {- const [count, unit] = window.split(" ");-- const unitName =- {- ms: "millisecond",- s: "second",- m: "minute",- h: "hour",- d: "day",- }[unit] ?? unit;-- return count === "1"- ? unitName- : `${count} ${pluralize(unitName, Number(count))}`;-};-// Enforces a rate limit policy for the given identifier, throwing a// rate_limit_exceeded DubApiError when the limit is exceededexport async function assertRateLimit({@@ -75,7 +57,7 @@ export async function assertRateLimit({window: policy.window,}): policy.message ??- `You've reached the rate limit of ${policy.attempts} attempts per ${formatWindow(policy.window)}. Please try again in ${retryAfter}.`;+ `Too many requests. Please try again in ${retryAfter}.`;throw new DubApiError({code: "rate_limit_exceeded",