diff --git a/packages/nuxt/src/app/composables/component.ts b/packages/nuxt/src/app/composables/component.ts index d6b2773ee2..a7fceef52d 100644 --- a/packages/nuxt/src/app/composables/component.ts +++ b/packages/nuxt/src/app/composables/component.ts @@ -47,10 +47,11 @@ export const defineNuxtComponent: typeof defineComponent = _fetchKeyBase: key, ...options, setup (props, ctx) { + const nuxtApp = useNuxtApp() const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {} const promises: Promise[] = [] if (options.asyncData) { - promises.push(runLegacyAsyncData(res, options.asyncData)) + promises.push(nuxtApp.runWithContext(() => runLegacyAsyncData(res, options.asyncData))) } if (options.head) {