diff --git a/packages/next/src/build/index.ts b/packages/next/src/build/index.ts index d9afcdc4344c7..5fa200bcd519f 100644 --- a/packages/next/src/build/index.ts +++ b/packages/next/src/build/index.ts @@ -1239,12 +1239,6 @@ export default async function build( pages404: true, caseSensitive: !!config.experimental.caseSensitiveRoutes, basePath: config.basePath, - streamingMetadataBotsUserAgent: - // Use the user configured UA regex if available, otherwise use the built-in default. - ( - config.experimental.streamingMetadataBotsUserAgent || - HEADLESS_BOT_UA_RE - ).source, redirects: redirects.map((r) => buildCustomRoute('redirect', r, restrictedRedirectPaths) ), @@ -1274,6 +1268,12 @@ export default async function build( }, } : undefined, + streamingMetadataBotsUserAgent: + // Use the user configured UA regex if available, otherwise use the built-in default. + ( + config.experimental.streamingMetadataBotsUserAgent || + HEADLESS_BOT_UA_RE + ).source, } satisfies RoutesManifest }) diff --git a/test/integration/custom-routes/test/index.test.js b/test/integration/custom-routes/test/index.test.js index d1f80e0071285..584bfa27abef7 100644 --- a/test/integration/custom-routes/test/index.test.js +++ b/test/integration/custom-routes/test/index.test.js @@ -2564,6 +2564,8 @@ const runTests = (isDev = false) => { prefetchSuffix: '.prefetch.rsc', suffix: '.rsc', }, + streamingMetadataBotsUserAgent: + 'Googlebot|Google-PageRenderer|AdsBot-Google|googleweblight|Storebot-Google', }) }) diff --git a/test/integration/dynamic-routing/test/index.test.js b/test/integration/dynamic-routing/test/index.test.js index 69c61598122b7..14602c0ac5f79 100644 --- a/test/integration/dynamic-routing/test/index.test.js +++ b/test/integration/dynamic-routing/test/index.test.js @@ -1519,6 +1519,8 @@ function runTests({ dev }) { prefetchSuffix: '.prefetch.rsc', suffix: '.rsc', }, + streamingMetadataBotsUserAgent: + 'Googlebot|Google-PageRenderer|AdsBot-Google|googleweblight|Storebot-Google', }) })