diff --git a/packages/next/server/post-process.ts b/packages/next/server/post-process.ts index 36e6f3911aefc..1839593519f33 100644 --- a/packages/next/server/post-process.ts +++ b/packages/next/server/post-process.ts @@ -180,7 +180,7 @@ class FontOptimizerMiddleware implements PostProcessMiddleware { async function postOptimizeHTML( pathname: string, - html: string, + content: string, renderOpts: RenderOpts, { inAmpMode, hybridAmp }: { inAmpMode: boolean; hybridAmp: boolean } ) { @@ -242,10 +242,10 @@ async function postOptimizeHTML( for (const postProcessor of postProcessors) { if (postProcessor) { - html = await postProcessor(html) + content = await postProcessor(content) } } - return html + return content } // Initialization @@ -257,4 +257,4 @@ registerPostProcessor( (options) => options.optimizeFonts || process.env.__NEXT_OPTIMIZE_FONTS ) -export { processHTML, postOptimizeHTML } +export { postOptimizeHTML } diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx index 1be5ef7c2bfca..97980e0d53342 100644 --- a/packages/next/server/render.tsx +++ b/packages/next/server/render.tsx @@ -465,7 +465,6 @@ export async function renderToHTML( ampPath = '', pageConfig = {}, buildManifest, - fontManifest, reactLoadableManifest, ErrorDebug, getStaticProps, @@ -1740,6 +1739,7 @@ export async function renderToHTML( const postOptimize = (html: string) => postOptimizeHTML(pathname, html, renderOpts, { inAmpMode, hybridAmp }) + if (generateStaticHTML) { const html = await streamToString(chainStreams(streams)) const optimizedHtml = await postOptimize(html)