From 8934c0477299ea7c098c78b3babd8c05027f2b89 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 26 Oct 2021 18:37:52 +0100 Subject: [PATCH] fix(nitro): support built `publicPath` (#1479) --- src/runtime/app/render.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/app/render.ts b/src/runtime/app/render.ts index b32342284d..cbc23e5c1a 100644 --- a/src/runtime/app/render.ts +++ b/src/runtime/app/render.ts @@ -12,6 +12,8 @@ const PAYLOAD_JS = '/payload.js' const getClientManifest = cachedImport(() => import('#build/dist/server/client.manifest.mjs')) const getSSRApp = cachedImport(() => import('#build/dist/server/server.mjs')) +const publicPath = (publicConfig.app && publicConfig.app.assetsPath) || process.env.PUBLIC_PATH || '/_nuxt' + const getSSRRenderer = cachedResult(async () => { // Load client manifest const clientManifest = await getClientManifest() @@ -21,7 +23,7 @@ const getSSRRenderer = cachedResult(async () => { if (!createSSRApp) { throw new Error('Server bundle is not available') } // Create renderer const { renderToString } = await import('#nitro-renderer') - return createRenderer((createSSRApp), { clientManifest, renderToString, publicPath: clientManifest.publicPath || '/_nuxt' }).renderToString + return createRenderer((createSSRApp), { clientManifest, renderToString, publicPath }).renderToString }) const getSPARenderer = cachedResult(async () => { @@ -37,7 +39,7 @@ const getSPARenderer = cachedResult(async () => { renderStyles: () => '', renderScripts: () => clientManifest.initial.map((s) => { const isMJS = !s.endsWith('.js') - return `` + return `` }).join('') } }