fix(nitro): inject payload for spa renderer (#1434)

This commit is contained in:
Daniel Roe 2021-10-25 11:36:38 +01:00 committed by GitHub
parent ad7e7551ec
commit c6f769e94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -27,7 +27,10 @@ const getSSRRenderer = cachedResult(async () => {
const getSPARenderer = cachedResult(async () => { const getSPARenderer = cachedResult(async () => {
const clientManifest = await getClientManifest() const clientManifest = await getClientManifest()
return (ssrContext) => { return (ssrContext) => {
ssrContext.nuxt = {} ssrContext.nuxt = {
serverRendered: false,
config: publicConfig
}
return { return {
html: '<div id="__nuxt"></div>', html: '<div id="__nuxt"></div>',
renderResourceHints: () => '', renderResourceHints: () => '',

View File

@ -104,8 +104,8 @@ export function useAsyncData<
return nuxt._asyncDataPromises[key] return nuxt._asyncDataPromises[key]
} }
const fetchOnServer = options.server !== false const fetchOnServer = options.server !== false && nuxt.payload.serverRendered
const clientOnly = options.server === false const clientOnly = options.server === false || !nuxt.payload.serverRendered
// Server side // Server side
if (process.server && fetchOnServer) { if (process.server && fetchOnServer) {