From 227697a1e514ce769179180d55b9a667a6c6ab1a Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 12 Apr 2024 10:54:32 +0000 Subject: [PATCH 1/2] fix(nextjs): 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 0d68448f81ba..5be7c922af96 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -137,25 +137,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 7c4db0d5935a6cd4f9d0fbe816e948e7baf4e913 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 12 Apr 2024 10:59:25 +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 5be7c922af96..f9c815fe6efb 100644 --- a/packages/nextjs/src/config/withSentryConfig.ts +++ b/packages/nextjs/src/config/withSentryConfig.ts @@ -143,7 +143,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') {