Skip to content

feat(nuxt, nitro): Serve the managed tunnel before the app's server middleware - #25418

Open
logaretm wants to merge 13 commits into
awad/tunnel-sveltekitfrom
awad/tunnel-nitro
Open

logaretm wants to merge 13 commits into
awad/tunnel-sveltekitfrom
awad/tunnel-nitro

Conversation

@logaretm

@logaretm logaretm commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

A Nitro app's own server/middleware, like an auth check, ran before anything Sentry registered and would block tunnel requests, fixed by putting the tunnel check first in h3's middleware on Nitro v3 and answering from the request hook on Nitro v2.

The e2e tunnel variants for Nuxt 4, Nuxt 5 and Nitro 3 check that the tunnel answers while an auth middleware rejects every other POST.

closes #20254

@logaretm
logaretm added this pull request to stack #25201 October 15, 2026 15:51
Comment thread packages/nuxt/src/runtime/plugins/tunnel-legacy.server.ts Outdated
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.53 kB +2.18% +649 B 🔺
@sentry/browser - with treeshaking flags 28.51 kB +1.75% +490 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 28.39 kB +1.7% +473 B 🔺
@sentry/browser (incl. Tracing) 52.77 kB +1.35% +699 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 52.77 kB +1.35% +698 B 🔺
@sentry/browser (incl. Tracing, Profiling) 55.74 kB +1.32% +721 B 🔺
@sentry/browser (incl. Tracing, Replay) 92.44 kB +0.68% +616 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.18 kB +0.62% +496 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 97.18 kB +0.66% +629 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 110.17 kB +0.63% +683 B 🔺
@sentry/browser (incl. Feedback) 48.09 kB +1.48% +699 B 🔺
@sentry/browser (incl. sendFeedback) 35.6 kB +1.9% +662 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.73 kB +1.71% +683 B 🔺
@sentry/browser (incl. Metrics) 31.54 kB +2.05% +633 B 🔺
@sentry/browser (incl. Logs) 31.81 kB +2.01% +626 B 🔺
@sentry/browser (incl. Metrics & Logs) 32.48 kB +2.11% +670 B 🔺
@sentry/react 32.33 kB +2% +631 B 🔺
@sentry/react (incl. Tracing) 55.02 kB +1.17% +633 B 🔺
@sentry/vue 38.68 kB +1.7% +643 B 🔺
@sentry/vue (incl. Tracing) 55.72 kB +1.31% +716 B 🔺
@sentry/svelte 30.56 kB +2.2% +657 B 🔺
@sentry/remix (Remix 3 client bundle) 57.8 kB +1.26% +715 B 🔺
CDN Bundle 32.11 kB +1.49% +470 B 🔺
CDN Bundle (incl. Tracing) 53.06 kB +0.91% +478 B 🔺
CDN Bundle (incl. Logs, Metrics) 34.31 kB +1.41% +474 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 55.01 kB +0.89% +483 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 75.26 kB +0.66% +492 B 🔺
CDN Bundle (incl. Tracing, Replay) 90.73 kB +0.53% +478 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.66 kB +0.52% +479 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 96.87 kB +0.49% +468 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.83 kB +0.5% +489 B 🔺
CDN Bundle - uncompressed 94.33 kB +1.24% +1.15 kB 🔺
CDN Bundle (incl. Tracing) - uncompressed 157.19 kB +0.74% +1.15 kB 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.87 kB +1.16% +1.15 kB 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.14 kB +0.72% +1.15 kB 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 230.91 kB +0.51% +1.15 kB 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.35 kB +0.42% +1.15 kB 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.3 kB +0.41% +1.15 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.06 kB +0.4% +1.15 kB 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 296.99 kB +0.39% +1.15 kB 🔺
@sentry/nextjs (client) 57.35 kB +1.09% +613 B 🔺
@sentry/sveltekit (client) 53.26 kB +1.54% +806 B 🔺
@sentry/core/server 42.85 kB +4.08% +1.68 kB 🔺
@sentry/core/browser 13.81 kB - -
@sentry/node 155.79 kB +0.42% +649 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 84.06 kB - -
@sentry/node - without tracing 97.47 kB +0.69% +661 B 🔺
@sentry/node - without channel injection 133.8 kB +0.47% +622 B 🔺
@sentry/aws-serverless 105.74 kB +0.69% +723 B 🔺
@sentry/cloudflare (withSentry) - minified 212.9 kB +0.96% +2.01 kB 🔺
@sentry/cloudflare (withSentry) 528.07 kB +0.94% +4.9 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 232.52 kB +0.88% +2.01 kB 🔺

View base workflow run

@logaretm
logaretm force-pushed the awad/tunnel-nitro branch 2 times, most recently from 9765090 to 9bad613 Compare October 15, 2026 17:15
@logaretm
logaretm force-pushed the awad/tunnel-nitro branch 2 times, most recently from c1733f2 to fdca10d Compare October 15, 2026 17:44
@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
logaretm force-pushed the awad/tunnel-nitro branch 2 times, most recently from 3596b0a to ec58ad6 Compare October 16, 2026 04:23
@logaretm
logaretm marked this pull request as ready for review October 19, 2026 19:36
@logaretm
logaretm requested a review from a team as a code owner October 19, 2026 19:36
@logaretm
logaretm requested review from mydea and s1gr1d and removed request for a team October 19, 2026 19:36

@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 dev-packages/e2e-tests/test-applications/nitro-3/tests/tunnel.test.ts Outdated
Comment thread packages/nuxt/test/common/tunnel.test.ts
@logaretm
logaretm requested review from a team as code owners October 19, 2026 20:08
@logaretm
logaretm requested review from JPeer264 and Lms24 and removed request for a team October 19, 2026 20:08

@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 eaaa873. Configure here.

// up a `NUXT_APP_BASE_URL` set at runtime.
setManagedTunnelDefaults({ basePath: (useRuntimeConfig() as { app?: { baseURL?: string } }).app?.baseURL });
const appFetch = nitroApp.fetch;
nitroApp.fetch = request => handleTunnelRequestIfMatched(request) ?? appFetch(request);

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 runs before Cloudflare client

Medium Severity

On Nitro v3 the managed tunnel now answers from a nitroApp.fetch wrapper, which is the worker entry. handleTunnelRequestIfMatched reads the active client, but sentryCloudflareNitroPlugin still installs that client inside localFetch. Tunnel POSTs can miss the match and fall through to app middleware, so the Cloudflare path this branch is meant to cover never serves the tunnel.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eaaa873. Configure here.

…iddleware

On Nitro v3, Nuxt and `@sentry/nitro` put the tunnel check first in h3's
middleware list, since Nitro runs the app's `server/middleware` before anything a
module registers and has no public way to go first. On Nitro v2, Nuxt answers
from the `request` hook.
`nuxt dev` opens the port before it can serve and answers 503 until then, while Playwright only waits for the port.

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.

Nuxt and Nitro managed tunnel

1 participant