fix(nuxt): ensure prerendered components are treated as islands (#21583)

This commit is contained in:
Daniel Roe 2023-06-16 15:47:59 +01:00 committed by GitHub
parent c73bed8c6d
commit 2a42a5f807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -79,6 +79,7 @@ export default defineComponent({
}
// TODO: Validate response
const result = await $fetch<NuxtIslandResponse>(url, {
responseType: 'json',
params: {
...props.context,
props: props.props ? JSON.stringify(props.props) : undefined

View File

@ -20,7 +20,10 @@ if (componentIslands) {
revivers.Island = ({ key, params }: any) => {
const nuxtApp = useNuxtApp()
if (!nuxtApp.isHydrating) {
nuxtApp.payload.data[key] = nuxtApp.payload.data[key] || $fetch(`/__nuxt_island/${key}`, params ? { params } : {}).then((r) => {
nuxtApp.payload.data[key] = nuxtApp.payload.data[key] || $fetch(`/__nuxt_island/${key}`, {
responseType: 'json',
...params ? { params } : {}
}).then((r) => {
nuxtApp.payload.data[key] = r
return r
})