From 4647d2f925cf3a87369b09d16db0c74ccec20f27 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 21 Mar 2024 11:51:20 +0000 Subject: [PATCH] fix(nuxt): don't warn about `definePageMeta` in server pages (#26422) --- packages/nuxt/src/pages/runtime/composables.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/pages/runtime/composables.ts b/packages/nuxt/src/pages/runtime/composables.ts index d81b305512..f7c4e5210d 100644 --- a/packages/nuxt/src/pages/runtime/composables.ts +++ b/packages/nuxt/src/pages/runtime/composables.ts @@ -3,6 +3,7 @@ import { getCurrentInstance } from 'vue' import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordRedirectOption } from '#vue-router' import { useRoute } from 'vue-router' import type { NitroRouteConfig } from 'nitropack' +import { useNuxtApp } from '#app/nuxt' import type { NuxtError } from '#app' export interface PageMeta { @@ -58,8 +59,9 @@ export const definePageMeta = (meta: PageMeta): void => { const component = getCurrentInstance()?.type try { const isRouteComponent = component && useRoute().matched.some(p => Object.values(p.components || {}).includes(component)) - if (isRouteComponent) { - // don't warn if it's being used in a route component + const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext + if (isRouteComponent || isRenderingServerPage) { + // don't warn if it's being used in a route component (or server page) return } } catch {