Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

edited rate limits

Steven Tey935b3e281c3f
diff --git a/lib/middleware/link.ts b/lib/middleware/link.ts
index 2e5cc75114..0ceef0a338 100644
--- a/lib/middleware/link.ts
+++ b/lib/middleware/link.ts
@@ -23,9 +23,10 @@ export default async function LinkMiddleware(
if (domain === "dub.sh") {
const ip = ipAddress(req) || LOCALHOST_IP;
const { success } = await ratelimit(
- 10,
- key === "github" ? "30 s" : "10 s",
- ).limit(ip);
+ // 25 redirects / day for dub.sh/github demo link, 10 redirects / 10s for other dub.sh links
+ key === "github" ? 25 : 10,
+ key === "github" ? "1 d" : "10 s",
+ ).limit(`${ip}:${domain}:${key}`);
if (!success) {
return new Response("Don't DDoS me pls 🥺", { status: 429 });
diff --git a/pages/api/edge/links/[key]/stats/[endpoint].ts b/pages/api/edge/links/[key]/stats/[endpoint].ts
index 03d6c308fc..a282b21cec 100644
--- a/pages/api/edge/links/[key]/stats/[endpoint].ts
+++ b/pages/api/edge/links/[key]/stats/[endpoint].ts
@@ -21,9 +21,10 @@ export default async function handler(req: NextRequest) {
if (domain === "dub.sh") {
const ip = ipAddress(req) || LOCALHOST_IP;
const { success } = await ratelimit(
- 10,
- key === "github" ? "30 s" : "10 s",
- ).limit(ip);
+ key === "github" ? 20 : 10,
+ key === "github" ? "1 d" : "10 s",
+ ).limit(`${ip}:${domain}:${key}:${endpoint}`);
+
if (!success) {
return new Response("Don't DDoS me pls 🥺", { status: 429 });
}