From 2fcadda2e515f331f0894a91bf6bf909c5a0ab1f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 19 Aug 2024 20:37:10 +0100 Subject: [PATCH] fix(nuxt): don't warn when data fetching in middleware (#28604) --- packages/nuxt/src/app/composables/asyncData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index f473871e7e..aedb67cb61 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -363,7 +363,7 @@ export function useAsyncData< if (import.meta.client) { // Setup hook callbacks once per instance const instance = getCurrentInstance() - if (import.meta.dev && !nuxtApp.isHydrating && (!instance || instance?.isMounted)) { + if (import.meta.dev && !nuxtApp.isHydrating && !nuxtApp._processingMiddleware /* internal flag */ && (!instance || instance?.isMounted)) { // @ts-expect-error private property console.warn(`[nuxt] [${options._functionName || 'useAsyncData'}] Component is already mounted, please use $fetch instead. See https://nuxt.com/docs/getting-started/data-fetching`) }