Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LDP-2424: Fix server API routes issue with i18n menus #192

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
12 changes: 8 additions & 4 deletions src/runtime/composables/useDrupalCe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable, but we should make sure this cannot happen again by adding a suiting test-coverage. It seems we currently lack test-coverage for the i18n case - let's add this!

}
}

const { data: menu, error } = await useFetch(menuPath, useFetchOptions)

if (error.value) {
Expand Down