diff --git a/README.md b/README.md index 4282388..7d940fe 100755 --- a/README.md +++ b/README.md @@ -130,10 +130,32 @@ Note: The `error` parameter is optional and can be omitted. ## Customizing API route rules +API route rules can be customized by using the `routeRules` option in Nuxt config: + +```javascript +export default defineNuxtConfig({ + nitro: { + routeRules: { + '/drupal-ce/**': { swr: true }, + } + } +}) +``` + +The default route rules implemented are: + +```javascript +'/api/drupal/**': { proxy: baseURLOrigin + '/**' }, // Base URL proxy. +'/api/drupal-ce/**': { proxy: options.baseURL + '/**' }, // Fetch page proxy. +'/api/menu/**': { proxy: options.baseURL + '/**', swr: nuxt.options.dev ? 0 : 300 } // Fetch menu proxy. +``` + +In order to disable this feature, `drupalCe.exposeAPIRouteRules` can be set to false: + ```javascript export default defineNuxtConfig({ - routeRules: { - '/drupal-ce/**': { swr: true }, + drupalCe: { + exposeAPIRouteRules: false } }) ``` diff --git a/src/runtime/composables/useDrupalCe.ts b/src/runtime/composables/useDrupalCe.ts index 93cac21..c6199c3 100644 --- a/src/runtime/composables/useDrupalCe.ts +++ b/src/runtime/composables/useDrupalCe.ts @@ -108,7 +108,7 @@ export const useDrupalCe = () => { } if (config.exposeAPIRouteRules) { - useFetchOptions.baseURL = useRequestURL().origin + '/api/menu' + useFetchOptions.baseURL = '/api/menu' } const { data: menu, error } = await useFetch(menuPath, useFetchOptions)