Pass debug log level to http-proxy-middleware
Signed-off-by: Boris Bera <bbera@coveo.com>
This commit is contained in:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user