Skip to content

Commit 1316994

Browse files
authored
fix: add triming operation before returning client IP (#300)
1 parent c09a665 commit 1316994

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/middleware/extractClientIp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ function extractClientIpFromRequestHeaders(
4141
* Only consider last IP as the source of truth as it has been added by AWS ECS Load balancer
4242
* See https://docs.aws.amazon.com/elasticloadbalancing/latest/application/x-forwarded-headers.html#x-forwarded-for-append
4343
*/
44-
return xForwardedForHeader.split(",").at(-1) ?? FALLBACK_CLIENT_IP_ADDRESS;
44+
return (
45+
xForwardedForHeader.split(",").at(-1)?.trim() ?? FALLBACK_CLIENT_IP_ADDRESS
46+
);
4547
}

0 commit comments

Comments
 (0)