Repository navigation
fix(web): locate views by X-Real-IP instead of the last forwarded hop - #23
Merged
Merged
Conversation
On Railway the last X-Forwarded-For entry is the edge's own address, so every self-hosted view was located at the edge POP (Miami for a viewer in Palm Bay). Use getClientIp, which reads X-Real-IP first, like the other self-hosted IP checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
After #21 and #22 deployed, a test view from
134.82.68.114(Palm Bay, FL in DB-IP; Railway's HTTP log shows that samesrcIp) was recorded as US / Florida / Miami. The request went through Railway'smia1edge.clientAddresstakes the lastX-Forwarded-Forhop off Vercel, and on Railway that hop is the edge's address, so every view would be located at the edge POP instead of the viewer.What
getClientIp(X-Real-IPfirst, then the firstX-Forwarded-Forentry), the helper upstream already uses for self-hosted IP checks. Railway documentsX-Real-IPas the client's address.X-Forwarded-Forwhose last hop is a different address and checks that the lookup usesX-Real-IP.Verified
analytics-track-route,visitor-location,mobile-cap-view-notificationtests pass;bun run typecheckclean.