Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/nextjs
SDK Version
10.75.3, also reproduced on 11.1.0
Framework Version
Next.js 14.2.4 (Pages Router, webpack), also reproduced in 15.5.4
Link to Sentry event
No response
Reproduction Example/SDK Setup
next.config.js:
const { withSentryConfig } = require('@sentry/nextjs/config');
module.exports = withSentryConfig(
{ basePath: '/base' },
{ telemetry: false, sourcemaps: { disable: true } }
);instrumentation.js:
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const Sentry = await import('@sentry/nextjs');
Sentry.init({
dsn: process.env.SENTRY_DSN,
beforeSend(event) {
console.log('[sentry event] request.url =', event.request?.url);
return event;
},
});
}
}pages/foo/bar.js:
export default function Page() {
return null;
}
export async function getServerSideProps() {
throw new Error('gSSP error');
}Steps to Reproduce
next build && next startcurl http://localhost:3000/base/foo/bar
Expected Result
event.request.url is http://localhost:3000/base/foo/bar - the URL that was actually requested.
Actual Result
[sentry event] request.url = http://localhost:3000/foo/bar
The basePath is missing. Same for /base -> http://localhost:3000/, and the query string is preserved (/base?q=1 → /?q=1).
Additional Context
Next.js strips basePath from req.url before running the page - the same applies to getInitialProps / _error wrappers that build request data from req.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Oct 2, 2026
JS-3870
chargome commentedon Oct 2, 2026
@nnn3d thanks for reporting, we'll look into it
fix(nextjs): Include basePath in request url of Pages Router errors (g…
github-actions commentedon Oct 7, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #24985, which was included in the 11.5.0 release.