From 91dfab3f111eb3ea25c69e55444ab0fc370fa169 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 5 Sep 2024 08:56:01 +0100 Subject: [PATCH] fix(nuxt): don't override vue instance with legacy `asyncData` (#28842) --- packages/nuxt/src/app/composables/component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/component.ts b/packages/nuxt/src/app/composables/component.ts index ebc234226c..e8bd93e20c 100644 --- a/packages/nuxt/src/app/composables/component.ts +++ b/packages/nuxt/src/app/composables/component.ts @@ -16,7 +16,7 @@ async function runLegacyAsyncData (res: Record | Promise '') : fetchKey) || ([_fetchKeyBase, route.fullPath, route.matched.findIndex(r => Object.values(r.components || {}).includes(vm.type))].join(':')) - const { data, error } = await useAsyncData(`options:asyncdata:${key}`, () => nuxtApp.runWithContext(() => fn(nuxtApp))) + const { data, error } = await useAsyncData(`options:asyncdata:${key}`, () => import.meta.server ? nuxtApp.runWithContext(() => fn(nuxtApp)) : fn(nuxtApp)) if (error.value) { throw createError(error.value) }