Skip to content

fix(browser): Send same-origin string tunnels as application/x-sentry-envelope - #26299

Merged
logaretm merged 1 commit into
developfrom
awad/same-origin-tunnel-content-type
Nov 11, 2026
Merged

logaretm merged 1 commit into
developfrom
awad/same-origin-tunnel-content-type

Conversation

@logaretm

@logaretm logaretm commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

While writing the docs for the new tunnel API i realized we have a discrepency in behavior regarding the headers set on a tunnel request.

Before: We set the application/x-sentry-envelope only if the user uses the new API options, so either tunnel: true or tunnel: { path: '/monitor' }. So the tunnel: '/monitor' option doesn't set that header.

The reasoning is we were worried about breaking CORS preflight header checks by adding that header, which is still a valid concern however it would typically apply to requests to a different origin. Requests on the same origin wouldn't trigger a preflight check, so the header has no risk there.

On all SDKs that doesn't really matter, but for Next.js it can break the tunnel if the user uses the new API directly with a fixed path like so:

// instrument.client.ts
Sentry.init({
  tunnel: '/fixed-path'
});

// instrument.server.ts
Sentry.init({
  integrations: [Sentry.serveTunnelIntegration()]
})

The way it works specifically on Next.js is that we match the route on vercel deployments using a re-write rule that targets any path with a application/x-sentry-envelope header, if the user uses the previous snippet the header is never sent so the tunnel never works.

Our shipped PRs wouldn't trigger this issue on their own because the new docs don't recommend this yet. Our merged implementation actually ensures the header to applied, but by accident since we normalize to tunnel: { path } format which uses the new API.

After: Now the distinction is different but more consistent, external URLs won't receive the header, while same origin requests will. This is a safer default.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 3b4f402 (PR test merge using develop at 86c5981)

Against: 86c5981 (develop) · base run #65750

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.13 kB +0.51% +151 B 🔺
@sentry/browser - with treeshaking flags 28.28 kB +0.54% +150 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 28.18 kB +0.55% +152 B 🔺
@sentry/browser (incl. Tracing) 52.41 kB +0.1% +51 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 52.41 kB +0.11% +56 B 🔺
@sentry/browser (incl. Tracing, Profiling) 55.38 kB +0.1% +52 B 🔺
@sentry/browser (incl. Tracing, Replay) 92.8 kB +0.05% +46 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.46 kB +0.06% +47 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 97.55 kB +0.06% +56 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 110.55 kB +0.07% +75 B 🔺
@sentry/browser (incl. Feedback) 47.73 kB +0.34% +159 B 🔺
@sentry/browser (incl. sendFeedback) 35.23 kB +0.46% +159 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.34 kB +0.41% +162 B 🔺
@sentry/browser (incl. Metrics) 31.7 kB +0.5% +156 B 🔺
@sentry/browser (incl. Logs) 31.99 kB +0.5% +157 B 🔺
@sentry/browser (incl. Metrics & Logs) 32.68 kB +0.5% +161 B 🔺
@sentry/react 31.99 kB +0.48% +150 B 🔺
@sentry/react (incl. Tracing) 54.87 kB +0.13% +67 B 🔺
@sentry/vue 38.46 kB +0.18% +69 B 🔺
@sentry/vue (incl. Tracing) 55.43 kB +0.1% +55 B 🔺
@sentry/svelte 30.15 kB +0.51% +150 B 🔺
@sentry/remix (Remix 3 client bundle) 58.03 kB +0.11% +60 B 🔺
CDN Bundle 31.93 kB +0.5% +156 B 🔺
CDN Bundle (incl. Tracing) 53 kB +0.12% +62 B 🔺
CDN Bundle (incl. Logs, Metrics) 34.76 kB +0.54% +184 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 55.51 kB +0.12% +64 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 76.09 kB +0.07% +46 B 🔺
CDN Bundle (incl. Tracing, Replay) 91.26 kB +0.05% +39 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.83 kB +0.07% +62 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 97.4 kB +0.07% +61 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 100 kB +0.08% +71 B 🔺
CDN Bundle - uncompressed 93.34 kB +0.49% +455 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 156.32 kB +0.12% +180 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.87 kB +0.45% +455 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 164.1 kB +0.11% +180 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.5 kB +0.09% +192 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 278.35 kB +0.07% +180 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 286.11 kB +0.07% +180 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.05 kB +0.07% +180 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.81 kB +0.07% +180 B 🔺
@sentry/nextjs (client) 57.77 kB +0.06% +31 B 🔺
@sentry/sveltekit (client) 52.97 kB +0.09% +45 B 🔺
@sentry/core/server 44.51 kB - -
@sentry/core/browser 14.02 kB - -
@sentry/node 157.81 kB +0.02% +16 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.31 kB - -
@sentry/node - without tracing 97.25 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 138.12 kB +0.02% +19 B 🔺
@sentry/aws-serverless 106.33 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 204.45 kB - -
@sentry/cloudflare (withSentry) 508.11 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 229.47 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 7 not successful, 19 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Failing after 21s Details
❌ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Failing after 31s Details
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (tunnel-dev) Test (optional) Failing after 22s Details
❌ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Failing after 27s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 21s Details
❌ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Failing after 23s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details

@logaretm
logaretm marked this pull request as ready for review November 11, 2026 14:15
@logaretm
logaretm requested review from a team, JPeer264 and stephanie-anderson November 11, 2026 14:15
@logaretm
logaretm requested a review from a team as a code owner November 11, 2026 14:15
@logaretm
logaretm requested review from s1gr1d and removed request for stephanie-anderson November 11, 2026 14:18
@logaretm
logaretm force-pushed the awad/same-origin-tunnel-content-type branch from be1f0da to bf140e1 Compare November 11, 2026 16:00
@logaretm
logaretm merged commit c491307 into develop Nov 11, 2026
836 of 851 checks passed
@logaretm
logaretm deleted the awad/same-origin-tunnel-content-type branch November 11, 2026 17:27
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.

2 participants