Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
686 B ยท 15 lines
TypeScript
12345678910111213141516/** * Client IP for access-gate checks. Prefer `x-real-ip`: Vercel's edge sets it to * the single verified client IP, with no comma-chain to parse. `x-forwarded-for`'s * leftmost entry is the classic spoof vector on paths that reach a route directly * โ `/api/*` bypasses the proxy middleware โ so only fall back to it when * `x-real-ip` is absent (e.g. local dev). A null result denies ip-restricted pages. */export function resolveClientIp(headers: { get(name: string): string | null;}): string | null { const real = headers.get("x-real-ip"); if (real) return real.trim(); const xff = headers.get("x-forwarded-for"); return xff?.split(",")[0]?.trim() ?? null;}