This commit is contained in:
jason
2026-04-20 15:49:01 -05:00
parent 381a31d607
commit b98837a72c
46 changed files with 8883 additions and 37 deletions
+14
View File
@@ -0,0 +1,14 @@
import type { NextRequest } from "next/server";
export function clientIp(req: NextRequest | Request): string | null {
const headers = "headers" in req ? req.headers : new Headers();
const fwd = headers.get("x-forwarded-for");
if (fwd) return fwd.split(",")[0]!.trim();
const real = headers.get("x-real-ip");
if (real) return real.trim();
return null;
}
export function userAgent(req: NextRequest | Request): string | null {
return req.headers.get("user-agent");
}