Skip to content

Commit

Permalink
fix(nitro): support built publicPath (#1479)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Oct 26, 2021
1 parent 6fd28f8 commit 8934c04
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime/app/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 () => {
Expand All @@ -37,7 +39,7 @@ const getSPARenderer = cachedResult(async () => {
renderStyles: () => '',
renderScripts: () => clientManifest.initial.map((s) => {
const isMJS = !s.endsWith('.js')
return `<script ${isMJS ? 'type="module"' : ''} src="${clientManifest.publicPath}${s}"></script>`
return `<script ${isMJS ? 'type="module"' : ''} src="${publicPath}${s}"></script>`
}).join('')
}
}
Expand Down

0 comments on commit 8934c04

Please sign in to comment.