diff --git a/packages/next/src/shared/lib/router/router.ts b/packages/next/src/shared/lib/router/router.ts index e74ae88268b16..e5178aecad39e 100644 --- a/packages/next/src/shared/lib/router/router.ts +++ b/packages/next/src/shared/lib/router/router.ts @@ -498,7 +498,10 @@ function fetchNextData({ headers: Object.assign( {} as HeadersInit, isPrefetch ? { purpose: 'prefetch' } : {}, - isPrefetch && hasMiddleware ? { 'x-middleware-prefetch': '1' } : {} + isPrefetch && hasMiddleware ? { 'x-middleware-prefetch': '1' } : {}, + process.env.NEXT_DEPLOYMENT_ID + ? { 'x-deployment-id': process.env.NEXT_DEPLOYMENT_ID } + : {} ), method: params?.method ?? 'GET', }) diff --git a/test/production/deployment-id-handling/app/middleware.ts b/test/production/deployment-id-handling/app/middleware.ts new file mode 100644 index 0000000000000..f37782f3cab3d --- /dev/null +++ b/test/production/deployment-id-handling/app/middleware.ts @@ -0,0 +1,5 @@ +import { NextRequest, NextResponse } from 'next/server' + +export function middleware(_req: NextRequest) { + return NextResponse.next() +} 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 +