Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vloss3 committed Oct 26, 2023
1 parent 1117aad commit d3927a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
```
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/useDrupalCe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d3927a8

Please sign in to comment.