diff --git a/plugins/proxy-backend/report.api.md b/plugins/proxy-backend/report.api.md index ef0fe37c96..90e7f54378 100644 --- a/plugins/proxy-backend/report.api.md +++ b/plugins/proxy-backend/report.api.md @@ -6,8 +6,8 @@ import { BackendFeature } from '@backstage/backend-plugin-api'; import { DiscoveryService } from '@backstage/backend-plugin-api'; import express from 'express'; -import { JsonObject } from '@backstage/types'; import { Logger } from 'winston'; +import { ProxyConfig } from '@backstage/plugin-proxy-node/alpha'; import { RootConfigService } from '@backstage/backend-plugin-api'; // @public @deprecated @@ -20,7 +20,7 @@ export default proxyPlugin; // @public @deprecated (undocumented) export interface RouterOptions { // (undocumented) - additionalEndpoints?: JsonObject; + additionalEndpoints?: ProxyConfig; // (undocumented) config: RootConfigService; // (undocumented) diff --git a/plugins/proxy-backend/src/service/router.ts b/plugins/proxy-backend/src/service/router.ts index b578a9aed6..934b1fcecb 100644 --- a/plugins/proxy-backend/src/service/router.ts +++ b/plugins/proxy-backend/src/service/router.ts @@ -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(proxyConfig).forEach(([route, proxyRouteConfig]) => { + Object.entries(proxyConfig).forEach(([route, proxyRouteConfig]) => { try { router.use( route,