From 91e81ce4e6228b61274b8ca93c15dc489d8bb90a Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 16 Oct 2022 21:33:22 +0800 Subject: [PATCH] fix(appDir): make css and font respect assetsPrefix --- packages/next/server/app-render.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index ba10a9f6e84cb..e38f78563e9ff 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -944,6 +944,8 @@ export async function renderToHTMLOrFlight( ComponentMod.pages ) + const assetPrefix = renderOpts.assetPrefix || '' + /** * Use the provided loader tree to create the React Component tree. */ @@ -1177,7 +1179,7 @@ export async function renderToHTMLOrFlight( ( @@ -1469,7 +1471,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], })) @@ -1516,11 +1518,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 )), ], }, @@ -1548,11 +1550,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 ), }, })