Pass debug log level to http-proxy-middleware

Signed-off-by: Boris Bera <bbera@coveo.com>
This commit is contained in:
Boris Bera
2023-03-07 12:04:57 -05:00
parent 4acd93dae1
commit a4dcd007e4
2 changed files with 6 additions and 10 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/plugin-proxy-backend': patch
---
Pass the current log level to `http-proxy-middleware` to ensure that proxies requests are shown when log level is set to `debug`.
Ensure that `@backstage/plugin-proxy-backend` logs the requests that it proxies when log level is set to `debug`.
+5 -9
View File
@@ -63,12 +63,6 @@ export interface ProxyConfig extends Options {
reviveRequestBody?: boolean;
}
function isValidHttpProxyMiddlewareLogLevel(
level: string,
): level is Exclude<Options['logLevel'], undefined> {
return ['debug', 'info', 'warn', 'error', 'silent'].includes(level);
}
// Creates a proxy middleware, possibly with defaults added on top of the
// given config.
export function buildMiddleware(
@@ -127,9 +121,11 @@ export function buildMiddleware(
// Attach the logger to the proxy config
fullConfig.logProvider = () => logger;
if (isValidHttpProxyMiddlewareLogLevel(logger.level)) {
fullConfig.logLevel = logger.level;
}
// http-proxy-middleware uses this log level to check if it should log the
// requests that it proxies. Setting this to the most verbose log level
// ensures that it always logs these requests. Our logger ends up deciding
// if the logs are displayed or not.
fullConfig.logLevel = 'debug';
// Only return the allowed HTTP headers to not forward unwanted secret headers
const requestHeaderAllowList = new Set<string>(