Skip to content

Commit d2c11a0

Browse files
committed
test: added internal config for testing
1 parent 856a4d1 commit d2c11a0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ export type SentryBuildOptions = {
437437
*/
438438
tunnelRoute?: string | boolean;
439439

440+
/**
441+
* @internal
442+
* Override the destination URL for tunnel rewrites (for E2E testing only)
443+
*/
444+
_tunnelRouteDestinationOverride?: string;
445+
440446
/**
441447
* Tree shakes Sentry SDK logger statements from the bundle.
442448
*/

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ function getFinalConfigObject(
125125
const resolvedTunnelRoute = resolveTunnelRoute(userSentryOptions.tunnelRoute);
126126
userSentryOptions.tunnelRoute = resolvedTunnelRoute || undefined;
127127

128-
setUpTunnelRewriteRules(incomingUserNextConfigObject, resolvedTunnelRoute);
128+
setUpTunnelRewriteRules(
129+
incomingUserNextConfigObject,
130+
resolvedTunnelRoute,
131+
userSentryOptions._tunnelRouteDestinationOverride,
132+
);
129133
}
130134
}
131135

@@ -389,7 +393,11 @@ function getFinalConfigObject(
389393
*
390394
* See https://nextjs.org/docs/api-reference/next.config.js/rewrites.
391395
*/
392-
function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: string): void {
396+
function setUpTunnelRewriteRules(
397+
userNextConfig: NextConfigObject,
398+
tunnelPath: string,
399+
destinationOverride?: string,
400+
): void {
393401
const originalRewrites = userNextConfig.rewrites;
394402

395403
// This function doesn't take any arguments at the time of writing but we future-proof
@@ -411,7 +419,7 @@ function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: s
411419
value: '(?<projectid>\\d*)',
412420
},
413421
],
414-
destination: 'https://o:orgid.ingest.sentry.io/api/:projectid/envelope/?hsts=0',
422+
destination: destinationOverride || 'https://o:orgid.ingest.sentry.io/api/:projectid/envelope/?hsts=0',
415423
};
416424

417425
const tunnelRouteRewriteWithRegion = {
@@ -435,7 +443,7 @@ function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: s
435443
value: '(?<region>[a-z]{2})',
436444
},
437445
],
438-
destination: 'https://o:orgid.ingest.:region.sentry.io/api/:projectid/envelope/?hsts=0',
446+
destination: destinationOverride || 'https://o:orgid.ingest.:region.sentry.io/api/:projectid/envelope/?hsts=0',
439447
};
440448

441449
// Order of these is important, they get applied first to last.

0 commit comments

Comments
 (0)