@@ -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