From 41f5d9cf0f1329fc6c2264d09d69998d9b497a7e Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Sat, 12 Oct 2024 10:19:05 -0400 Subject: [PATCH 1/8] fix: set x-deployment-id to every prefetch request --- packages/next/src/shared/lib/router/router.ts | 6 +++-- .../app/pages/index.tsx | 4 ++++ .../deployment-id-handling.test.ts | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/next/src/shared/lib/router/router.ts b/packages/next/src/shared/lib/router/router.ts index 91d7de55f36a1..ca25bf73c4850 100644 --- a/packages/next/src/shared/lib/router/router.ts +++ b/packages/next/src/shared/lib/router/router.ts @@ -444,6 +444,7 @@ function fetchRetry( method: options.method || 'GET', headers: Object.assign({}, options.headers, { 'x-nextjs-data': '1', + 'x-deployment-id': process.env.NEXT_DEPLOYMENT_ID, }), }).then((response) => { return !response.ok && attempts > 1 && response.status >= 500 @@ -1921,8 +1922,9 @@ export default class Router implements BaseRouter { try { let props: Record | undefined - const { page: Component, styleSheets } = - await this.fetchComponent('/_error') + const { page: Component, styleSheets } = await this.fetchComponent( + '/_error' + ) const routeInfo: CompletePrivateRouteInfo = { props, diff --git a/test/production/deployment-id-handling/app/pages/index.tsx b/test/production/deployment-id-handling/app/pages/index.tsx index 077744d736c13..f8890e6702348 100644 --- a/test/production/deployment-id-handling/app/pages/index.tsx +++ b/test/production/deployment-id-handling/app/pages/index.tsx @@ -1,6 +1,7 @@ import testImage from '../public/test.jpg' import Image from 'next/image' import styles from './styles.module.css' +import Link from 'next/link' export default function Page() { return ( @@ -8,6 +9,9 @@ export default function Page() {

hello pages

{process.env.NEXT_DEPLOYMENT_ID}

test image + + Edge +