Skip to content

Commit

Permalink
fix: LDP-2424: Fix server API routes issue with i18n menus (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
vloss3 authored Feb 19, 2024
1 parent 76b4560 commit 02b60fd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/runtime/composables/useDrupalCe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,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)
Expand All @@ -125,6 +121,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) {
Expand Down

0 comments on commit 02b60fd

Please sign in to comment.