Skip to content

Next.JS tunnelPath rewrite does not take basePath into account #8293

@IgnusG

Description

@IgnusG

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.53.1

Framework Version

7.53.1

Link to Sentry event

No response

SDK Setup

let nextConfig = {
  basePath: '/something',
}

nextConfig = withSentryConfig(
  nextConfig,
  {
    silent: true,
    release: env.BUILD_ID,
  },
  {
    widenClientFileUpload: true,
    transpileClientSDK: true,
    tunnelRoute: '/monitoring',
    hideSourceMaps: true,
    disableLogger: true,
  },
);

Steps to Reproduce

Sentry tries to connect to example.com/monitoring instead of example.com/something/monitoring.

Changing tunnelRoute to /something/monitoring doesn't work either as the rewrite doesn't match since Next.JS would be trying to match /something${tunnelRoute} which is /something/something/monitoring.

Expected Result

Either the base path is taken into account automatically by the plugin or the rewrite specifies basePath: false and its left up to the user to provide the base path manually when specifying the tunnel route eg. tunnelRoute: `${MY_BASE_PATH}/monitoring`.

Actual Result

Using basePath along with tunnelRoute from sentry results in 404 errors if the application is actually deployed on that base path and a different application handles routes outside of it.

Reference https://github.com/getsentry/sentry-javascript/blob/develop/packages/nextjs/src/config/withSentryConfig.ts

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions