Skip to content

Commit c9feacf

Browse files
committed
add-api-proxy: Add override examples and use serverDrupalBaseUrl
1 parent 82c5d53 commit c9feacf

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ is added automatically to requests. Defaults to `false`.
9393
- `useLocalizedMenuEndpoint`: If enabled, the menu endpoint will use a language prefix as configured by [nuxtjs/i18n](https://v8.i18n.nuxtjs.org) module. Defaults to `true`.
9494

9595
## Overriding options with environment variables
96-
Runtime config values can be overriden with environment variables via `NUXT_PUBLIC_` prefix, e.g. `NUXT_PUBLIC_DRUPAL_BASE_URL`.
96+
Runtime config values can be overriden with environment variables via `NUXT_PUBLIC_` prefix, example overrides:
97+
98+
- `drupalBaseUrl` -> `NUXT_PUBLIC_DRUPAL_CE_DRUPAL_BASE_URL`
99+
- `serverDrupalBaseUrl` -> `NUXT_PUBLIC_DRUPAL_CE_SERVER_DRUPAL_BASE_URL`
100+
- `menuBaseUrl` -> `NUXT_PUBLIC_DRUPAL_CE_MENU_BASE_URL`
97101

98102
## Deprecated options
99103

src/runtime/server/api/drupalCe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default defineEventHandler(async (event) => {
22
const path = `/${event.context.params._.replace('api/drupal-ce', '')}`
3-
const drupalBaseUrl = useRuntimeConfig().public.drupalCe.baseURL
3+
const drupalCe = useRuntimeConfig().public.drupalCe
4+
const drupalBaseUrl = drupalCe.serverDrupalBaseUrl || drupalCe.baseURL
45
return await proxyRequest(event, drupalBaseUrl + path)
56
});

src/runtime/server/api/menu.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default defineEventHandler(async (event) => {
2-
const menuBaseUrl = useRuntimeConfig().public.drupalCe.menuBaseUrl
2+
const drupalCe = useRuntimeConfig().public.drupalCe
3+
const menuBaseUrl = drupalCe.serverDrupalBaseUrl || drupalCe.menuBaseUrl
34
const menu = event.context.params._
45
return await proxyRequest(event, `${menuBaseUrl}/${menu}`, {
56
headers: {

0 commit comments

Comments
 (0)