mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(nuxt): render server components when ssr: false
(#22869)
This commit is contained in:
parent
a5cc858a4c
commit
6198a11514
@ -171,7 +171,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (import.meta.client && !nuxtApp.isHydrating && props.lazy) {
|
if (import.meta.client && !nuxtApp.isHydrating && props.lazy) {
|
||||||
fetchComponent()
|
fetchComponent()
|
||||||
} else if (import.meta.server || !nuxtApp.isHydrating) {
|
} else if (import.meta.server || !nuxtApp.isHydrating || !nuxtApp.payload.serverRendered) {
|
||||||
await fetchComponent()
|
await fetchComponent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import escapeRE from 'escape-string-regexp'
|
|||||||
import fse from 'fs-extra'
|
import fse from 'fs-extra'
|
||||||
import { withoutLeadingSlash } from 'ufo'
|
import { withoutLeadingSlash } from 'ufo'
|
||||||
/* eslint-disable import/no-restricted-paths */
|
/* eslint-disable import/no-restricted-paths */
|
||||||
|
import defu from 'defu'
|
||||||
import pagesModule from '../pages/module'
|
import pagesModule from '../pages/module'
|
||||||
import metaModule from '../head/module'
|
import metaModule from '../head/module'
|
||||||
import componentsModule from '../components/module'
|
import componentsModule from '../components/module'
|
||||||
@ -283,6 +284,12 @@ async function initNuxt (nuxt: Nuxt) {
|
|||||||
priority: 10, // built-in that we do not expect the user to override
|
priority: 10, // built-in that we do not expect the user to override
|
||||||
filePath: resolve(nuxt.options.appDir, 'components/nuxt-island')
|
filePath: resolve(nuxt.options.appDir, 'components/nuxt-island')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!nuxt.options.ssr) {
|
||||||
|
nuxt.options.ssr = true
|
||||||
|
nuxt.options.nitro.routeRules ||= {}
|
||||||
|
nuxt.options.nitro.routeRules['/**'] = defu(nuxt.options.nitro.routeRules['/**'], { ssr: false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add experimental cross-origin prefetch support using Speculation Rules API
|
// Add experimental cross-origin prefetch support using Speculation Rules API
|
||||||
|
@ -259,7 +259,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
|||||||
noSSR:
|
noSSR:
|
||||||
!!(process.env.NUXT_NO_SSR) ||
|
!!(process.env.NUXT_NO_SSR) ||
|
||||||
event.context.nuxt?.noSSR ||
|
event.context.nuxt?.noSSR ||
|
||||||
routeOptions.ssr === false ||
|
(routeOptions.ssr === false && !islandContext) ||
|
||||||
(import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(url) : false),
|
(import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(url) : false),
|
||||||
head,
|
head,
|
||||||
error: !!ssrError,
|
error: !!ssrError,
|
||||||
|
Loading…
Reference in New Issue
Block a user