chore: Refactor a little bit to use proxyconfig instead

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2025-01-14 07:59:08 +01:00
parent 4c0a674aef
commit e11c2fc648
2 changed files with 7 additions and 6 deletions
+5 -4
View File
@@ -63,7 +63,7 @@ export interface RouterOptions {
discovery: DiscoveryService;
skipInvalidProxies?: boolean;
reviveConsumedRequestBodies?: boolean;
additionalEndpoints?: JsonObject;
additionalEndpoints?: ProxyConfig;
}
// Creates a proxy middleware, possibly with defaults added on top of the
@@ -310,10 +310,11 @@ export async function createRouterInternal(
const externalUrl = await options.discovery.getExternalBaseUrl('proxy');
const { pathname: pathPrefix } = new URL(externalUrl);
const proxyConfig = {
const proxyConfig: ProxyConfig = {
...(options.additionalEndpoints ?? {}),
...readProxyConfig(options.config, options.logger),
};
configureMiddlewares(
proxyOptions,
currentRouter,
@@ -356,10 +357,10 @@ function configureMiddlewares(
},
router: express.Router,
pathPrefix: string,
proxyConfig: any,
proxyConfig: ProxyConfig,
httpRouterService?: HttpRouterService,
) {
Object.entries<any>(proxyConfig).forEach(([route, proxyRouteConfig]) => {
Object.entries(proxyConfig).forEach(([route, proxyRouteConfig]) => {
try {
router.use(
route,