Skip to content

Fix getClientIp whitespace-only X-Forwarded-For fallback - #70

Merged
allocsys merged 2 commits into
mainfrom
fix-issue-67-getclientip-whitespace
Jul 31, 2026
Merged

Fix getClientIp whitespace-only X-Forwarded-For fallback#70
allocsys merged 2 commits into
mainfrom
fix-issue-67-getclientip-whitespace

Conversation

@allocsys

Copy link
Copy Markdown
Owner

Fixes #67.

getClientIp only checked truthiness of the raw X-Forwarded-For header before using it, not whether it was meaningful after trimming. A whitespace-only header (e.g. " ") passed the presence check, got trimmed to "", and that empty string was returned instead of falling back to req.socket.remoteAddress.

Now the trimmed forwarded value is only used if it's non-empty; otherwise it falls back to the socket address, same as when the header is absent entirely.

@allocsys
allocsys merged commit f800c8d into main Jul 31, 2026
2 checks passed
@allocsys
allocsys deleted the fix-issue-67-getclientip-whitespace branch July 31, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getClientIp: whitespace-only X-Forwarded-For returns "" instead of falling back to socket address

1 participant