Skip to content

feat(nextjs): Serve the tunnel from the app with a DSN-derived path - #25424

Draft
logaretm wants to merge 9 commits into
awad/tunnel-solidstartfrom
awad/tunnel-nextjs
Draft

logaretm wants to merge 9 commits into
awad/tunnel-solidstartfrom
awad/tunnel-nextjs

Conversation

@logaretm

@logaretm logaretm commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

tunnelRoute rewrote envelopes straight to sentry.io, which leaked the user's cookies and only worked for SaaS DSNs, fixed by answering it from a generated app route on the DSN-derived path.

The unit tests cover the rewrites, the injected options and the route file generation, and e2e variants check the App and Pages routers on Turbopack and webpack.

closes #25466

@logaretm
logaretm added this pull request to stack #25201 October 15, 2026 20:01
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 31.03 kB +3.87% +1.16 kB 🔺
@sentry/browser - with treeshaking flags 28.82 kB +2.87% +803 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 28.72 kB +2.86% +798 B 🔺
@sentry/browser (incl. Tracing) 53.24 kB +2.26% +1.17 kB 🔺
@sentry/browser (incl. Tracing + Span Streaming) 53.24 kB +2.24% +1.17 kB 🔺
@sentry/browser (incl. Tracing, Profiling) 56.24 kB +2.24% +1.23 kB 🔺
@sentry/browser (incl. Tracing, Replay) 92.99 kB +1.28% +1.17 kB 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.48 kB +1% +799 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 97.74 kB +1.24% +1.19 kB 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 110.67 kB +1.09% +1.19 kB 🔺
@sentry/browser (incl. Feedback) 48.6 kB +2.55% +1.21 kB 🔺
@sentry/browser (incl. sendFeedback) 36.12 kB +3.37% +1.18 kB 🔺
@sentry/browser (incl. FeedbackAsync) 41.25 kB +3% +1.2 kB 🔺
@sentry/browser (incl. Metrics) 32.03 kB +3.65% +1.13 kB 🔺
@sentry/browser (incl. Logs) 32.32 kB +3.65% +1.14 kB 🔺
@sentry/browser (incl. Metrics & Logs) 33.01 kB +3.78% +1.2 kB 🔺
@sentry/react 32.84 kB +3.58% +1.13 kB 🔺
@sentry/react (incl. Tracing) 55.52 kB +2.08% +1.13 kB 🔺
@sentry/vue 39.21 kB +3.09% +1.17 kB 🔺
@sentry/vue (incl. Tracing) 56.25 kB +2.26% +1.24 kB 🔺
@sentry/svelte 31.06 kB +3.88% +1.16 kB 🔺
@sentry/remix (Remix 3 client bundle) 58.28 kB +2.11% +1.2 kB 🔺
CDN Bundle 32.36 kB +2.27% +716 B 🔺
CDN Bundle (incl. Tracing) 53.3 kB +1.38% +723 B 🔺
CDN Bundle (incl. Logs, Metrics) 34.55 kB +2.13% +718 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 55.25 kB +1.34% +728 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 75.52 kB +1.01% +751 B 🔺
CDN Bundle (incl. Tracing, Replay) 90.97 kB +0.8% +717 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.96 kB +0.86% +785 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 97.14 kB +0.77% +737 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.14 kB +0.81% +792 B 🔺
CDN Bundle - uncompressed 95.04 kB +2% +1.86 kB 🔺
CDN Bundle (incl. Tracing) - uncompressed 157.88 kB +1.19% +1.85 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.58 kB +1.87% +1.86 kB 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.84 kB +1.15% +1.85 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.62 kB +0.82% +1.86 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 278.05 kB +0.67% +1.85 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.99 kB +0.66% +1.85 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.75 kB +0.64% +1.85 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.69 kB +0.63% +1.85 kB 🔺
@sentry/nextjs (client) 57.78 kB +1.74% +985 B 🔺
@sentry/sveltekit (client) 53.67 kB +2.34% +1.23 kB 🔺
@sentry/core/server 41.85 kB +1.78% +730 B 🔺
@sentry/core/browser 13.81 kB - -
@sentry/node 153.84 kB +0.5% +757 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 84.04 kB - -
@sentry/node - without tracing 95.58 kB +0.75% +707 B 🔺
@sentry/node - without channel injection 131.89 kB +0.58% +748 B 🔺
@sentry/aws-serverless 103.84 kB +0.79% +805 B 🔺
@sentry/cloudflare (withSentry) - minified 212.53 kB +0.92% +1.93 kB 🔺
@sentry/cloudflare (withSentry) 526.33 kB +0.73% +3.8 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 231.2 kB +1.29% +2.92 kB 🔺

View base workflow run

Comment thread packages/nextjs/src/config/types.ts Outdated
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nextjs/src/config/withSentryConfig/tunnel.ts
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nextjs/src/config/withSentryConfig/tunnel.ts
Comment thread packages/nextjs/src/common/sentryTunnelRouteHandler.ts
Comment thread packages/nextjs/src/common/utils/dropMiddlewareTunnelRequests.ts
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5472088. Configure here.

basePath: userNextConfig.basePath ?? '',
...(path && { path }),
...(allowedDsns && { allowedDsns }),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tunnel ignores Next.js trailingSlash

Medium Severity

getManagedTunnelOptions copies basePath from the Next.js config but not trailingSlash, so the browser posts to the slashless DSN path. With trailingSlash: true, Next.js 308s that POST before beforeFiles rewrites, and the DSN rewrite source also omits the optional trailing slash that the fixed-path rewrite includes. Unload-time keepalive fetches often will not follow that redirect, so events never reach the tunnel.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5472088. Configure here.

This branch has not been deployed

No deployments
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.

Next.js managed tunnel on the tunnel route handler

1 participant