-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve!: LDP-2461: remove deprecated baseURL option and fix configur…
…ation fallbacks to apply at runtime (#204) * improve: LDP-2461: Rename routeRules to serverApiProxy * LDP-2461: Add BC for exposeAPIRouteRules * LDP-2461: Remove check for absolute URL in serverApiProxy * LDP-2461: Add dist for testing * LDP-2461: Remove baseURL, add utility functions for base urls * LDP-2461: Update tests * improve: Rename exposeAPIRouteRules to serverApiProxy and fix type errors * LDP-2461: Remove dist * LDP-2461: Add useFetchDrupal helper * LDP-2461: Add getCeApiEndpoint helper * LDP-2461: Create composable for base urls * LDP-2461: Add dist * LDP-2461: Add server compatible utils for getBaseUrls * LDP-2461: Add useDrupalCe server composables * LDP-2461: Improve variable name in menu route * LDP-2461: Remove dist
- Loading branch information
Showing
14 changed files
with
64 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useRuntimeConfig } from '#imports' | ||
|
||
export const getDrupalBaseUrl = () => { | ||
const config = useRuntimeConfig().public.drupalCe | ||
return import.meta.server && config.serverDrupalBaseUrl ? config.serverDrupalBaseUrl : config.drupalBaseUrl | ||
} | ||
|
||
export const getMenuBaseUrl = () => { | ||
const config = useRuntimeConfig().public.drupalCe | ||
return config.menuBaseUrl ? config.menuBaseUrl : getDrupalBaseUrl() + config.ceApiEndpoint | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { defineEventHandler, proxyRequest, getRouterParams } from 'h3' | ||
import { getDrupalBaseUrl } from '../../composables/useDrupalCe/server' | ||
import { useRuntimeConfig } from '#imports' | ||
|
||
export default defineEventHandler(async (event) => { | ||
const params = getRouterParams(event)._ | ||
const path = params ? '/' + params : '' | ||
const drupalCe = useRuntimeConfig().public.drupalCe | ||
const drupalUrl = (drupalCe.serverDrupalBaseUrl || drupalCe.drupalBaseUrl) + drupalCe.ceApiEndpoint | ||
const { ceApiEndpoint } = useRuntimeConfig().public.drupalCe | ||
// Remove x-forwarded-proto header as it causes issues with the request. | ||
delete event.req.headers['x-forwarded-proto'] | ||
return await proxyRequest(event, drupalUrl + path) | ||
return await proxyRequest(event, getDrupalBaseUrl() + ceApiEndpoint + path) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters