fix ip stuff
Some checks failed
Code quality checks / biome (push) Failing after 7s

This commit is contained in:
Seth 2025-05-16 00:18:29 -04:00
parent e6b8175662
commit 29da0ce6a4

View file

@ -48,16 +48,9 @@ const postAnalytics = async (
server: Bun.Server, server: Bun.Server,
) => { ) => {
const cfIp = req.headers.get("CF-Connecting-IP"); const cfIp = req.headers.get("CF-Connecting-IP");
const realIp = req.headers.get("X-Real-IP"); //const realIp = req.headers.get("X-Real-IP");
const forwardedIp = req.headers.get("X-Forwarded-For"); const forwardedIp = req.headers.get("X-Forwarded-For");
const serverIp = server.requestIP(req)?.address; //const serverIp = server.requestIP(req)?.address;
console.log({
cfIp,
realIp,
forwardedIp,
serverIp,
});
return await fetch("https://plausible.creations.works/api/event", { return await fetch("https://plausible.creations.works/api/event", {
method: "POST", method: "POST",
@ -65,7 +58,7 @@ const postAnalytics = async (
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": req.headers.get("user-agent") || "", "User-Agent": req.headers.get("user-agent") || "",
"X-Forwarded-For": String( "X-Forwarded-For": String(
cfIp || realIp || forwardedIp?.split(",")[0] || serverIp, cfIp || forwardedIp?.split(",")[0],
), ),
}, },
body: JSON.stringify({ body: JSON.stringify({