Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/runtime/composables/useDrupalCe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>(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)
Expand Down