From 6136f640456959e6471cbf7d41f6a44eed9671f1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 27 Jan 2026 01:33:43 +0000 Subject: ip fallback --- lib/app.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/app.ts b/lib/app.ts index bf208973..7632520f 100644 --- a/lib/app.ts +++ b/lib/app.ts @@ -45,9 +45,14 @@ app.addHook("preHandler", async (req) => { if (ignore.some((path) => url.startsWith(path))) return; if (req.method === "GET" && url.startsWith("/users")) return; + const xff = req.headers["x-forwarded-for"]; + const forwardedIp = Array.isArray(xff) ? xff[0] : xff?.split(",")[0]?.trim(); + const ip = req.headers["cf-connecting-ip"] || forwardedIp || req.ip; + reqLogger.info({ method: req.method, url, + ip, headers: req.headers, query: req.query, body: req.body, -- cgit v1.2.3