From d1df5b3115c088e17e3851f67f563daeb5e0a34b Mon Sep 17 00:00:00 2001 From: Tom Hackshaw <42124348+et0and@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:02:53 +1300 Subject: [PATCH] Delete src/utils/filterRequests.ts --- src/utils/filterRequests.ts | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/utils/filterRequests.ts diff --git a/src/utils/filterRequests.ts b/src/utils/filterRequests.ts deleted file mode 100644 index 00d5d3e..0000000 --- a/src/utils/filterRequests.ts +++ /dev/null @@ -1,33 +0,0 @@ -export function shouldFilterRequest(req: Request): boolean { - const ip = - req.headers.get("x-forwarded-for") || - req.headers.get("x-real-ip") || - "unknown"; - const userAgent = req.headers.get("user-agent") || ""; - const referer = req.headers.get("referer") || ""; - - // Filter localhost visits - if (ip === "::1" || ip === "127.0.0.1") { - return true; - } - - // Filter specific IP addresses (example) - const filteredIPs = process.env.FILTERED_IPS - ? process.env.FILTERED_IPS.split(",") - : []; - if (filteredIPs.includes(ip)) { - return true; - } - - // Filter based on user agent (e.g., exclude bots) - if (userAgent.toLowerCase().includes("bot")) { - return true; - } - - // Filter based on referer (e.g., exclude visits from your development domain) - if (referer.includes("localhost") || referer.includes("127.0.0.1")) { - return true; - } - - return false; -}