| 2072 | curRes.headers.get('x-nextjs-cache') || curRes.headers.get('x-vercel-cache') |
| 2073 | |
| 2074 | export function getDeploymentId(appDir: string, isDev: boolean) { |
| 2075 | let requiredServerFiles |
| 2076 | if (!isDev) { |
| 2077 | // File isn't written in dev, but it might still exist because it was created by a prior |
| 2078 | // production build. |
| 2079 | try { |
| 2080 | requiredServerFiles = JSON.parse( |
| 2081 | readFileSync( |
| 2082 | path.join(appDir, getDistDir(), 'required-server-files.json'), |
| 2083 | 'utf8' |
| 2084 | ) |
| 2085 | ) |
| 2086 | } catch {} |
| 2087 | } |
| 2088 | |
| 2089 | const deploymentId: string | undefined = |
| 2090 | requiredServerFiles?.config?.deploymentId |
| 2091 | const immutableAssetToken: string | undefined = |
| 2092 | requiredServerFiles?.config?.experimental?.immutableAssetToken |
| 2093 | const assetToken: string | undefined = immutableAssetToken || deploymentId |
| 2094 | |
| 2095 | return { |
| 2096 | deploymentId, |
| 2097 | getDeploymentIdQuery(ampersand = false) { |
| 2098 | return deploymentId ? `${ampersand ? '&' : '?'}dpl=${deploymentId}` : '' |
| 2099 | }, |
| 2100 | assetToken, |
| 2101 | getAssetQuery(ampersand = false) { |
| 2102 | return assetToken ? `${ampersand ? '&' : '?'}dpl=${assetToken}` : '' |
| 2103 | }, |
| 2104 | } |
| 2105 | } |