Title: Next.js tunnel handler mode records the server IP instead of the client IP on sentry.io · Issue #26154 · getsentry/sentry-javascript · GitHub
Open Graph Title: Next.js tunnel handler mode records the server IP instead of the client IP on sentry.io · Issue #26154 · getsentry/sentry-javascript
X Title: Next.js tunnel handler mode records the server IP instead of the client IP on sentry.io · Issue #26154 · getsentry/sentry-javascript
Description: Package: @sentry/nextjs 11.10.0 (@sentry/core 11.10.0), Next.js 16.4.5, self-hosted Node behind Cloudflare and nginx, SaaS ingest on the de region What happens With tunnelRoute: "/monitoring" and src/app/sentry-tunnel/route.ts containing...
Open Graph Description: Package: @sentry/nextjs 11.10.0 (@sentry/core 11.10.0), Next.js 16.4.5, self-hosted Node behind Cloudflare and nginx, SaaS ingest on the de region What happens With tunnelRoute: "/monitoring" and s...
X Description: Package: @sentry/nextjs 11.10.0 (@sentry/core 11.10.0), Next.js 16.4.5, self-hosted Node behind Cloudflare and nginx, SaaS ingest on the de region What happens With tunnelRoute: "/monitoring&q...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/26154
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Next.js tunnel handler mode records the server IP instead of the client IP on sentry.io","articleBody":"**Package:** `@sentry/nextjs` 11.10.0 (`@sentry/core` 11.10.0), Next.js 16.4.5, self-hosted Node behind Cloudflare and nginx, SaaS ingest on the `de` region\n\n### What happens\n\nWith `tunnelRoute: \"/monitoring\"` and `src/app/sentry-tunnel/route.ts` containing `export { POST } from \"@sentry/nextjs/tunnel\"` (handler mode), browser events arrive with the server's IP as `user.ip_address`, not the visitor's. Geo and \"users impacted\" for browser issues then reflect the server.\n\nIn rewrite mode, the same setup recorded the visitor's IP correctly.\n\n### Reproduction\n\n1. Send an event with `\"user\": {\"ip_address\": \"{{auto}}\"}` through the tunnel route from a client.\n2. The request reaches the app with `CF-Connecting-IP` and `X-Forwarded-For` set to the client IP.\n3. The stored event has `user.ip_address` = the server's IP.\n\n### Likely cause\n\n`forwardHeaders` in `packages/core/src/utils/tunnelForward.ts` sends the client IP only as `X-Sentry-Forwarded-For`. Relay's `ForwardedFor` extractor says *\"The Sentry SaaS infrastructure sets this header\"*, so on sentry.io the value seems to be overwritten with the connecting IP, which is our server.\n\nRewrite mode works because the proxy passes all request headers through, including `CF-Connecting-IP`, which Relay ranks first.\n\n### Possible fix\n\nAlso forward the client IP in a header that Relay prefers and that SaaS doesn't overwrite. Or document that handler mode loses the client IP on SaaS.\n","author":{"url":"https://github.com/tvanbeek","@type":"Person","name":"tvanbeek"},"datePublished":"2026-11-05T16:47:49Z","url":"https://github.com/getsentry/sentry-javascript/issues/26154"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7bfec1a9-5db1-6963-04f1-07f65a9aee41 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABFC:2A3275:5130E6:71DF3A:6B044470 |
| html-safe-nonce | f3d0dc967a93a92e2cdebd4949af413a6c5685d8a2a5891b297808a2332d8092 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkZDOjJBMzI3NTo1MTMwRTY6NzFERjNBOjZCMDQ0NDcwIiwidmlzaXRvcl9pZCI6IjUwNjkxNTU3Njg3NDI0NjI1NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b86f7c9c4336c602de20579544c01b1afa5b2d818ca76cb8a49bebf324b96cf0 |
| hovercard-subject-tag | issue:6227588458 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/26154/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8b52e9a913db4cef8db4e94ab909d910725201bb2ff12591507321316d28f32/getsentry/sentry-javascript/issues/26154 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8b52e9a913db4cef8db4e94ab909d910725201bb2ff12591507321316d28f32/getsentry/sentry-javascript/issues/26154 |
| og:image:alt | Package: @sentry/nextjs 11.10.0 (@sentry/core 11.10.0), Next.js 16.4.5, self-hosted Node behind Cloudflare and nginx, SaaS ingest on the de region What happens With tunnelRoute: "/monitoring" and s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tvanbeek |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width