mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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) {
|
||||
fetchComponent()
|
||||
} else if (import.meta.server || !nuxtApp.isHydrating) {
|
||||
} else if (import.meta.server || !nuxtApp.isHydrating || !nuxtApp.payload.serverRendered) {
|
||||
await fetchComponent()
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import escapeRE from 'escape-string-regexp'
|
||||
import fse from 'fs-extra'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
/* eslint-disable import/no-restricted-paths */
|
||||
import defu from 'defu'
|
||||
import pagesModule from '../pages/module'
|
||||
import metaModule from '../head/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
|
||||
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
|
||||
|
@ -259,7 +259,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
||||
noSSR:
|
||||
!!(process.env.NUXT_NO_SSR) ||
|
||||
event.context.nuxt?.noSSR ||
|
||||
routeOptions.ssr === false ||
|
||||
(routeOptions.ssr === false && !islandContext) ||
|
||||
(import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(url) : false),
|
||||
head,
|
||||
error: !!ssrError,
|
||||
|
Loading…
Reference in New Issue
Block a user