Skip to content

fix(nextjs): Normalize trailing slashes in App Router route parameterization#19365

Open
logaretm wants to merge 3 commits intodevelopfrom
awad/js-1669-nextjs-fix-trailing-slash-pageload-matching
Open

fix(nextjs): Normalize trailing slashes in App Router route parameterization#19365
logaretm wants to merge 3 commits intodevelopfrom
awad/js-1669-nextjs-fix-trailing-slash-pageload-matching

Conversation

@logaretm
Copy link
Member

When trailingSlash: true is set in next.config.js, Next.js appends a trailing / to all URLs (e.g., /about becomes /about/).

This caused pageload transactions to be incorrectly named /:slug* (the catch-all route) for nearly all routes.

Something to consider: This does not preserve the actual route visited, it normalizes by trimming the slashes for all routes, so if the user visits /about/ it will be reported as /about in traces. I noticed we have precedent for that with react-router so I followed that.

Closes #19241

@linear
Copy link

linear bot commented Feb 17, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

Codecov Results 📊


Generated by Codecov Action

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.56 kB - -
@sentry/browser - with treeshaking flags 24.08 kB - -
@sentry/browser (incl. Tracing) 42.36 kB - -
@sentry/browser (incl. Tracing, Profiling) 47.03 kB - -
@sentry/browser (incl. Tracing, Replay) 81.18 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.8 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.87 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.03 kB - -
@sentry/browser (incl. Feedback) 42.29 kB - -
@sentry/browser (incl. sendFeedback) 30.23 kB - -
@sentry/browser (incl. FeedbackAsync) 35.22 kB - -
@sentry/browser (incl. Metrics) 26.74 kB - -
@sentry/browser (incl. Logs) 26.88 kB - -
@sentry/browser (incl. Metrics & Logs) 27.56 kB - -
@sentry/react 27.33 kB - -
@sentry/react (incl. Tracing) 44.72 kB - -
@sentry/vue 30.01 kB - -
@sentry/vue (incl. Tracing) 44.22 kB - -
@sentry/svelte 25.58 kB - -
CDN Bundle 28.11 kB - -
CDN Bundle (incl. Tracing) 43.2 kB - -
CDN Bundle (incl. Logs, Metrics) 28.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.02 kB - -
CDN Bundle (incl. Tracing, Replay) 80.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.4 kB - -
CDN Bundle - uncompressed 82.22 kB - -
CDN Bundle (incl. Tracing) - uncompressed 127.93 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.81 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.42 kB - -
@sentry/nextjs (client) 47.12 kB +0.11% +49 B 🔺
@sentry/sveltekit (client) 42.81 kB - -
@sentry/node-core 52.15 kB +0.02% +9 B 🔺
@sentry/node 166.53 kB +0.01% +8 B 🔺
@sentry/node - without tracing 93.95 kB +0.02% +12 B 🔺
@sentry/aws-serverless 109.45 kB +0.01% +9 B 🔺

View base workflow run

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 App Router + trailingSlash: true seems to cause pageload transactions to be named /:slug* for unrelated routes

1 participant