mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): use $fetch.raw
in dev client mode for islands (#21904)
This commit is contained in:
parent
02a6aecd4e
commit
52a427d583
@ -5,6 +5,7 @@ import { appendResponseHeader } from 'h3'
|
|||||||
import { useHead } from '@unhead/vue'
|
import { useHead } from '@unhead/vue'
|
||||||
import { randomUUID } from 'uncrypto'
|
import { randomUUID } from 'uncrypto'
|
||||||
import { withQuery } from 'ufo'
|
import { withQuery } from 'ufo'
|
||||||
|
import type { FetchResponse } from 'ofetch'
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths
|
// eslint-disable-next-line import/no-restricted-paths
|
||||||
import type { NuxtIslandResponse } from '../../core/runtime/nitro/renderer'
|
import type { NuxtIslandResponse } from '../../core/runtime/nitro/renderer'
|
||||||
@ -42,7 +43,8 @@ export default defineComponent({
|
|||||||
const hashId = computed(() => hash([props.name, props.props, props.context]))
|
const hashId = computed(() => hash([props.name, props.props, props.context]))
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const event = useRequestEvent()
|
const event = useRequestEvent()
|
||||||
const eventFetch = process.server ? event.fetch : globalThis.fetch
|
// TODO: remove use of `$fetch.raw` when nitro 503 issues on windows dev server are resolved
|
||||||
|
const eventFetch = process.server ? event.fetch : process.dev ? $fetch.raw : globalThis.fetch
|
||||||
const mounted = ref(false)
|
const mounted = ref(false)
|
||||||
onMounted(() => { mounted.value = true })
|
onMounted(() => { mounted.value = true })
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ export default defineComponent({
|
|||||||
...props.context,
|
...props.context,
|
||||||
props: props.props ? JSON.stringify(props.props) : undefined
|
props: props.props ? JSON.stringify(props.props) : undefined
|
||||||
}))
|
}))
|
||||||
const result = await r.json() as NuxtIslandResponse
|
const result = process.server || !process.dev ? await r.json() : (r as FetchResponse<NuxtIslandResponse>)._data
|
||||||
// TODO: support passing on more headers
|
// TODO: support passing on more headers
|
||||||
if (process.server && process.env.prerender) {
|
if (process.server && process.env.prerender) {
|
||||||
const hints = r.headers.get('x-nitro-prerender')
|
const hints = r.headers.get('x-nitro-prerender')
|
||||||
|
Loading…
Reference in New Issue
Block a user