From 44b1ab77e8a9efd38c78b0822256e5c775104cef Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 7 Aug 2023 11:33:03 +0200 Subject: [PATCH] proxy-backend: let config reader check for objects Signed-off-by: Patrik Oldsberg --- plugins/proxy-backend/src/service/router.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/proxy-backend/src/service/router.ts b/plugins/proxy-backend/src/service/router.ts index f8f6a3fdab..61fddb60ed 100644 --- a/plugins/proxy-backend/src/service/router.ts +++ b/plugins/proxy-backend/src/service/router.ts @@ -192,21 +192,15 @@ export function buildMiddleware( } function readProxyConfig(config: Config, logger: Logger): unknown { - const endpoints = config.getOptional('proxy.endpoints'); + const endpoints = config.getOptionalConfig('proxy.endpoints')?.get(); if (endpoints) { - if (typeof endpoints !== 'object' || Array.isArray(endpoints)) { - throw new Error('proxy configuration must be an object'); - } return endpoints; } - const root = config.getOptional('proxy'); + const root = config.getOptionalConfig('proxy')?.get(); if (!root) { return {}; } - if (typeof root !== 'object' || Array.isArray(root)) { - throw new Error('deprecated proxy configuration must be an object'); - } const rootEndpoints = Object.fromEntries( Object.entries(root).filter(([key]) => key.startsWith('/')),