File tree Expand file tree Collapse file tree 7 files changed +18
-9
lines changed
components/router-reducer
server/route-modules/pages Expand file tree Collapse file tree 7 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ import {
4141 urlToUrlWithoutFlightMarker ,
4242} from '../../route-params'
4343import type { NormalizedSearch } from '../segment-cache/cache-key'
44- import { deploymentId } from '../../../shared/lib/deployment-id'
44+ import { getDeploymentId } from '../../../shared/lib/deployment-id'
4545
4646const createFromReadableStream =
4747 createFromReadableStreamBrowser as ( typeof import ( 'react-server-dom-webpack/client.browser' ) ) [ 'createFromReadableStream' ]
@@ -330,6 +330,7 @@ export async function createFetch<T>(
330330 headers [ 'Next-Test-Fetch-Priority' ] = fetchPriority
331331 }
332332
333+ const deploymentId = getDeploymentId ( )
333334 if ( deploymentId ) {
334335 headers [ 'x-deployment-id' ] = deploymentId
335336 }
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ import {
5656 omitUnusedArgs ,
5757} from '../../../../shared/lib/server-reference-info'
5858import { revalidateEntireCache } from '../../segment-cache/cache'
59- import { deploymentId } from '../../../../shared/lib/deployment-id'
59+ import { getDeploymentId } from '../../../../shared/lib/deployment-id'
6060
6161const createFromFetch =
6262 createFromFetchBrowser as ( typeof import ( 'react-server-dom-webpack/client.browser' ) ) [ 'createFromFetch' ]
@@ -111,6 +111,7 @@ async function fetchServerAction(
111111 ) ,
112112 }
113113
114+ const deploymentId = getDeploymentId ( )
114115 if ( deploymentId ) {
115116 headers [ 'x-deployment-id' ] = deploymentId
116117 }
Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ declare const __webpack_require__: any
22declare let __webpack_public_path__ : string
33
44import {
5- deploymentId ,
5+ getDeploymentId ,
66 getDeploymentIdQueryOrEmptyString ,
77} from '../shared/lib/deployment-id'
88
99// If we have a deployment ID, we need to append it to the webpack chunk names
1010// I am keeping the process check explicit so this can be statically optimized
11- if ( deploymentId ) {
11+ if ( getDeploymentId ( ) ) {
1212 const suffix = getDeploymentIdQueryOrEmptyString ( )
1313 const getChunkScriptFilename = __webpack_require__ . u
1414 __webpack_require__ . u = ( ...args : any [ ] ) =>
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ import type {
4242 GetStaticPaths ,
4343 GetStaticProps ,
4444} from '../../../types'
45- import { deploymentId } from '../../../shared/lib/deployment-id'
45+ import { getDeploymentId } from '../../../shared/lib/deployment-id'
4646
4747export const getHandler = ( {
4848 srcPage : originalSrcPage ,
@@ -258,7 +258,7 @@ export const getHandler = ({
258258 buildId,
259259 customServer :
260260 Boolean ( routerServerContext ?. isCustomServer ) || undefined ,
261- deploymentId : deploymentId ,
261+ deploymentId : getDeploymentId ( ) ,
262262 } ,
263263 renderOpts : {
264264 params,
Original file line number Diff line number Diff line change 1- export let deploymentId : string | undefined = process . env . NEXT_DEPLOYMENT_ID
1+ // This could also be a variable instead of a function, but some unit tests want to change the ID at
2+ // runtime. Even though that would never happen in a real deployment.
3+ export function getDeploymentId ( ) : string | undefined {
4+ return process . env . NEXT_DEPLOYMENT_ID
5+ }
26
37export function getDeploymentIdQueryOrEmptyString ( ) : string {
8+ let deploymentId = getDeploymentId ( )
49 if ( deploymentId ) {
510 return `?dpl=${ deploymentId } `
611 }
Original file line number Diff line number Diff line change 11import type { ImageLoaderPropsWithConfig } from './image-config'
22import { findClosestQuality } from './find-closest-quality'
3- import { deploymentId } from './deployment-id'
3+ import { getDeploymentId } from './deployment-id'
44
55function defaultLoader ( {
66 config,
@@ -95,6 +95,7 @@ function defaultLoader({
9595
9696 const q = findClosestQuality ( quality , config )
9797
98+ let deploymentId = getDeploymentId ( )
9899 return `${ config . path } ?url=${ encodeURIComponent ( src ) } &w=${ width } &q=${ q } ${
99100 src . startsWith ( '/_next/static/media/' ) && deploymentId
100101 ? `&dpl=${ deploymentId } `
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ import { interpolateAs } from './utils/interpolate-as'
4343import { disableSmoothScrollDuringRouteTransition } from './utils/disable-smooth-scroll'
4444import type { Params } from '../../../server/request/params'
4545import { MATCHED_PATH_HEADER } from '../../../lib/constants'
46- import { deploymentId } from '../deployment-id'
46+ import { getDeploymentId } from '../deployment-id'
4747
4848let resolveRewrites : typeof import ( './utils/resolve-rewrites' ) . default
4949if ( process . env . __NEXT_HAS_REWRITES ) {
@@ -498,6 +498,7 @@ function fetchNextData({
498498 unstable_skipClientCache,
499499} : FetchNextDataParams ) : Promise < FetchDataOutput > {
500500 const { href : cacheKey } = new URL ( dataHref , window . location . href )
501+ const deploymentId = getDeploymentId ( )
501502 const getData = ( params ?: { method ?: 'HEAD' | 'GET' } ) =>
502503 fetchRetry ( dataHref , isServerRender ? 3 : 1 , {
503504 headers : Object . assign (
You can’t perform that action at this time.
0 commit comments