Skip to content

fix(core): forward visitor IP to Umami and Plausible via X-Forwarded-For - #78

Merged
deer merged 2 commits into
mainfrom
analytics
Apr 28, 2026
Merged

deer merged 2 commits into
mainfrom
analytics

Conversation

@deer

@deer deer commented Apr 27, 2026

Copy link
Copy Markdown
Owner
  • formatUmami was not forwarding the visitor IP at all — Umami was geo-locating events using the Deno Deploy data center IP instead of the real visitor's IP, producing bogus country data
  • Moved IP forwarding for Umami from the JSON payload body (which Umami ignores) to the X-Forwarded-For request header, matching how Plausible already worked
  • Centralized IP extraction into the middleware: x-forwarded-for from the incoming request (set by upstream proxies) with fallback to ctx.info.remoteAddr (the real client IP on Deno Deploy for direct browser requests)
  • Plausible and custom providers updated to receive the same centrally-resolved IP rather than each re-reading headers independently
  • Added tests covering the x-forwarded-forremoteAddr fallback chain and asserting IP appears in outgoing headers (not the payload body) for Umami

@deer
deer merged commit ca66851 into main Apr 28, 2026
4 checks passed
@deer
deer deleted the analytics branch April 28, 2026 05:36
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.

1 participant