Skip to content

Commit 02b60fd

Browse files
authored
fix: LDP-2424: Fix server API routes issue with i18n menus (#192)
1 parent 76b4560 commit 02b60fd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/runtime/composables/useDrupalCe.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ export const useDrupalCe = () => {
113113
const baseMenuPath = config.menuEndpoint.replace('$$$NAME$$$', name)
114114
const menuPath = ref(baseMenuPath)
115115

116-
if (config.exposeAPIRouteRules) {
117-
useFetchOptions.baseURL = '/api/menu'
118-
}
119-
120116
if (config.useLocalizedMenuEndpoint && nuxtApp.$i18n) {
121117
// API path with localization
122118
menuPath.value = nuxtApp.$localePath('/' + baseMenuPath)
@@ -125,6 +121,14 @@ export const useDrupalCe = () => {
125121
})
126122
}
127123

124+
if (config.exposeAPIRouteRules) {
125+
useFetchOptions.baseURL = '/api/menu'
126+
// menuPath should not start with a slash.
127+
if (menuPath.value.startsWith('/')) {
128+
menuPath.value = menuPath.value.substring(1)
129+
}
130+
}
131+
128132
const { data: menu, error } = await useFetch(menuPath, useFetchOptions)
129133

130134
if (error.value) {

0 commit comments

Comments
 (0)