From fe4de06a6fd4833b18ba7c30062359b67c674250 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 12 Apr 2024 10:51:50 +0000 Subject: [PATCH 1/2] fix(nextjs/v7): Fix `tunnelRoute` matching logic for hybrid cloud --- packages/nextjs/src/config/withSentryConfig.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index ac43a6f03549..7cdaddbf9013 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -133,25 +133,28 @@ function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: s { type: 'query', key: 'r', // short for region - we keep it short so matching is harder for ad-blockers - value: '(?\\[a-z\\]{2})', + value: '(?[a-z]{2})', }, ], destination: 'https://o:orgid.ingest.:region.sentry.io/api/:projectid/envelope/?hsts=0', }; + // Order of these is important, they get applied last to first. + const newRewrites = [tunnelRouteRewriteWithRegion, tunnelRouteRewrite]; + if (typeof originalRewrites !== 'function') { - return [tunnelRouteRewriteWithRegion, tunnelRouteRewrite]; + return newRewrites; } // @ts-expect-error Expected 0 arguments but got 1 - this is from the future-proofing mentioned above, so we don't care about it const originalRewritesResult = await originalRewrites(...args); if (Array.isArray(originalRewritesResult)) { - return [tunnelRouteRewriteWithRegion, tunnelRouteRewrite, ...originalRewritesResult]; + return [...newRewrites, ...originalRewritesResult]; } else { return { ...originalRewritesResult, - beforeFiles: [tunnelRouteRewriteWithRegion, tunnelRouteRewrite, ...(originalRewritesResult.beforeFiles || [])], + beforeFiles: [...newRewrites, ...(originalRewritesResult.beforeFiles || [])], }; } }; From 86faa95a3d1ad5839259b066a2e9c4af63a9f7fb Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 12 Apr 2024 10:59:56 +0000 Subject: [PATCH 2/2] wording --- packages/nextjs/src/config/withSentryConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/withSentryConfig.ts b/packages/nextjs/src/config/withSentryConfig.ts index 7cdaddbf9013..7c19c0a100be 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -139,7 +139,7 @@ function setUpTunnelRewriteRules(userNextConfig: NextConfigObject, tunnelPath: s destination: 'https://o:orgid.ingest.:region.sentry.io/api/:projectid/envelope/?hsts=0', }; - // Order of these is important, they get applied last to first. + // Order of these is important, they get applied first to last. const newRewrites = [tunnelRouteRewriteWithRegion, tunnelRouteRewrite]; if (typeof originalRewrites !== 'function') {