fix: address final review findings

This commit is contained in:
ajnart committed 2026-08-20 14:48:02 +02:00
1 parent c732c5045d
commit ca20431d84
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -11,5 +11,11 @@ export const userAgent = (headers: Headers) => {
export type DeviceType = "console" | "mobile" | "tablet" | "smarttv" | "wearable" | "embedded" | undefined;
export const ipAddressFromHeaders = (headers: Headers): string | null => {
return headers.get("x-forwarded-for");
const forwardedFor = headers.get("x-forwarded-for");
if (!forwardedFor) return null;
// The bundled nginx proxy appends the transport peer to this chain. Using
// the last hop prevents a caller-controlled prefix from creating arbitrary
// rate-limit identities.
return forwardedFor.split(",").at(-1)?.trim() || null;
};