fix: improve header value retrieval for IP address extraction (#1865)

This commit is contained in:
Özgür ÖZALP
2025-04-08 20:58:16 +03:00
committed by GitHub
parent 8263382b92
commit cbbd650efa

View File

@@ -26,7 +26,7 @@ export function getIp(
];
const headers = "headers" in req ? req.headers : req;
for (const key of keys) {
const value = headers.get(key);
const value = "get" in headers ? headers.get(key): headers[key];
if (typeof value === "string") {
const ip = value.split(",")[0].trim();
if (ip) return ip;