import type { Context as HonoContext } from "hono"; export function getClientIp(context: HonoContext): string | undefined { const headers = context.req.raw.headers; const cfIp = headers.get("cf-connecting-ip"); if (cfIp) return cfIp.trim(); const forwarded = headers.get("x-forwarded-for"); if (forwarded) { const firstIp = forwarded.split(",")[0]?.trim(); if (firstIp) return firstIp; } const realIp = headers.get("x-real-ip"); if (realIp) return realIp.trim(); return undefined; }