diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index 947139b8c2b89..236f832e7891f 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -872,6 +872,8 @@ export async function renderToHTMLOrFlight( ComponentMod.pages ) + const assetPrefix = renderOpts.assetPrefix || '' + /** * Use the provided loader tree to create the React Component tree. */ @@ -1105,7 +1107,7 @@ export async function renderToHTMLOrFlight( ( @@ -1397,7 +1399,7 @@ export async function renderToHTMLOrFlight( polyfill.endsWith('.js') && !polyfill.endsWith('.module.js') ) .map((polyfill) => ({ - src: `${renderOpts.assetPrefix || ''}/_next/${polyfill}`, + src: `${assetPrefix}/_next/${polyfill}`, integrity: subresourceIntegrityManifest?.[polyfill], })) @@ -1444,11 +1446,11 @@ export async function renderToHTMLOrFlight( bootstrapScripts: [ ...(subresourceIntegrityManifest ? buildManifest.rootMainFiles.map((src) => ({ - src: `${renderOpts.assetPrefix || ''}/_next/` + src, + src: `${assetPrefix}/_next/` + src, integrity: subresourceIntegrityManifest[src], })) : buildManifest.rootMainFiles.map( - (src) => `${renderOpts.assetPrefix || ''}/_next/` + src + (src) => `${assetPrefix}/_next/` + src )), ], }, @@ -1476,11 +1478,11 @@ export async function renderToHTMLOrFlight( // Include hydration scripts in the HTML bootstrapScripts: subresourceIntegrityManifest ? buildManifest.rootMainFiles.map((src) => ({ - src: `${renderOpts.assetPrefix || ''}/_next/` + src, + src: `${assetPrefix}/_next/` + src, integrity: subresourceIntegrityManifest[src], })) : buildManifest.rootMainFiles.map( - (src) => `${renderOpts.assetPrefix || ''}/_next/` + src + (src) => `${assetPrefix}/_next/` + src ), }, })