From 212c522cd6fdfde1c54c7e15fc4a81e587aee57d Mon Sep 17 00:00:00 2001 From: Alexandru Date: Fri, 9 Feb 2024 17:37:28 +0200 Subject: [PATCH] fix: LDP-2424: Fix server API routes issue with i18n menus --- src/runtime/composables/useDrupalCe.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/runtime/composables/useDrupalCe.ts b/src/runtime/composables/useDrupalCe.ts index 72f2bf1d..e3f100cf 100644 --- a/src/runtime/composables/useDrupalCe.ts +++ b/src/runtime/composables/useDrupalCe.ts @@ -105,10 +105,6 @@ export const useDrupalCe = () => { const baseMenuPath = config.menuEndpoint.replace('$$$NAME$$$', name) const menuPath = ref(baseMenuPath) - if (config.exposeAPIRouteRules) { - useFetchOptions.baseURL = '/api/menu' - } - if (config.useLocalizedMenuEndpoint && nuxtApp.$i18n) { // API path with localization menuPath.value = nuxtApp.$localePath('/' + baseMenuPath) @@ -117,6 +113,14 @@ export const useDrupalCe = () => { }) } + if (config.exposeAPIRouteRules) { + useFetchOptions.baseURL = '/api/menu' + // menuPath should not start with a slash. + if (menuPath.value.startsWith('/')) { + menuPath.value = menuPath.value.substring(1) + } + } + const { data: menu, error } = await useFetch(menuPath, useFetchOptions) if (error.value) {