proxy-backend: let config reader check for objects
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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('/')),
|
||||
|
||||
Reference in New Issue
Block a user