diff --git a/src/runtime/composables/index.ts b/src/runtime/composables/index.ts index 2124fefc0..c3e815cf8 100644 --- a/src/runtime/composables/index.ts +++ b/src/runtime/composables/index.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ import { useRequestHeaders, useCookie as useNuxtCookie } from '#imports' -import { ref, computed, watch, onUnmounted } from 'vue' +import { ref, computed, watch, onUnmounted, unref } from 'vue' import { parseAcceptLanguage, wrapComposable, runtimeDetectBrowserLanguage } from '../internal' import { DEFAULT_DYNAMIC_PARAMS_KEY, localeCodes, normalizedLocales } from '#build/i18n.options.mjs' import { getActiveHead } from 'unhead' @@ -80,6 +80,10 @@ export function useSetI18nParams(seo?: SeoAttributesOptions): SetI18nParamsFunct const currentLocale = getNormalizedLocales(locales).find(l => l.code === locale) || { code: locale } const currentLocaleLanguage = currentLocale.language + if (!unref(i18n.baseUrl)) { + console.warn('I18n `baseUrl` is required to generate valid SEO tag links.') + } + const setMeta = () => { const metaObject: HeadParam = { link: [], diff --git a/src/runtime/routing/compatibles/head.ts b/src/runtime/routing/compatibles/head.ts index 0a37eac07..94193c773 100644 --- a/src/runtime/routing/compatibles/head.ts +++ b/src/runtime/routing/compatibles/head.ts @@ -33,8 +33,13 @@ export function localeHead( meta: [] } + const i18nBaseUrl = unref(i18n.baseUrl) + if (!i18nBaseUrl) { + console.warn('I18n `baseUrl` is required to generate valid SEO tag links.') + } + // skip if no locales or baseUrl is set - if (unref(i18n.locales) == null || unref(i18n.baseUrl) == null) { + if (unref(i18n.locales) == null || i18nBaseUrl == null) { return metaObject }