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.

Move HEAD request check to `detectBot` (#3602)

Steven Tey1a0d53edcedb
diff --git a/apps/web/lib/middleware/utils/detect-bot.ts b/apps/web/lib/middleware/utils/detect-bot.ts
index f2140fdbe4..fc814fe062 100644
--- a/apps/web/lib/middleware/utils/detect-bot.ts
+++ b/apps/web/lib/middleware/utils/detect-bot.ts
@@ -10,6 +10,11 @@ export const detectBot = (req: Request) => {
return true;
}
+ // HEAD requests are generally from bots, real users will always use GET requests
+ if (req.method === "HEAD") {
+ return true;
+ }
+
// Check ua
const ua = userAgent(req);
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index 5831141f96..f3e0e59f81 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -71,11 +71,6 @@ export async function recordClick({
return null;
}
- // don't track HEAD requests to avoid non-user traffic from inflating click count
- if (req.method === "HEAD") {
- return null;
- }
-
const ua = userAgent(req);
const isBot = detectBot(req);