diff --git a/src/runtime/composables/useDrupalCe/index.ts b/src/runtime/composables/useDrupalCe/index.ts index 8568ff21..fd93f60b 100644 --- a/src/runtime/composables/useDrupalCe/index.ts +++ b/src/runtime/composables/useDrupalCe/index.ts @@ -327,10 +327,40 @@ export const useDrupalCe = () => { // Override baseURL specifically for menu endpoints if (config.serverApiProxy && !skipDrupalCeApiProxy) { - useFetchOptions.baseURL = '/api/menu' + useFetchOptions.baseURL = '/api/menu/' } else { - useFetchOptions.baseURL = getDrupalBaseUrl() + getCeApiEndpoint(false) + useFetchOptions.baseURL = `${getDrupalBaseUrl() + getCeApiEndpoint(false)}/` + } + + if (import.meta.client && !nuxtApp.isHydrating) { + const menu = ref(undefined) + const { + key: _key, + getCachedData: _getCachedData, + default: _default, + transform: _transform, + pick: _pick, + deep: _deep, + dedupe: _dedupe, + lazy: _lazy, + immediate: _immediate, + watch: _watch, + ...clientFetchOptions + } = useFetchOptions + + try { + menu.value = await $fetch(menuPath.value, { + ...clientFetchOptions, + baseURL: useFetchOptions.baseURL, + }) + } + catch (error: unknown) { + const wrappedError = { value: error } + overrideErrorHandler ? overrideErrorHandler(wrappedError) : menuErrorHandler(wrappedError) + } + + return menu } const { data: menu, error } = await useFetch(menuPath, useFetchOptions)