From 11fad09c74acf7a3da9d452204197626485e013d Mon Sep 17 00:00:00 2001 From: Carlos Esteban Lopez Date: Fri, 16 Jun 2023 17:41:52 -0500 Subject: [PATCH] fix(kubernetes-backend): Swap `.header()` for `.headers[]` Signed-off-by: Carlos Esteban Lopez --- .../src/service/KubernetesProxy.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/kubernetes-backend/src/service/KubernetesProxy.ts b/plugins/kubernetes-backend/src/service/KubernetesProxy.ts index 7e03d863b8..36617bbbad 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesProxy.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesProxy.ts @@ -140,19 +140,15 @@ export class KubernetesProxy { changeOrigin: true, pathRewrite: { [`^${originalReq.baseUrl}`]: '' }, router: async req => { - const isWS = req.headers.upgrade === 'websocket'; - const cluster = isWS - ? originalCluster - : await this.getClusterForRequest(req); - const url = new URL(cluster.url); - const ca = bufferFromFileOrString('', cluster.caData)?.toString(); - // Re-evaluate the cluster on each request, in case it has changed + const cluster = await this.getClusterForRequest(req); + const url = new URL(cluster.url); + return { protocol: url.protocol, host: url.hostname, port: url.port, - ca, + ca: bufferFromFileOrString('', cluster.caData)?.toString(), }; }, onError: (error, req, res) => { @@ -179,7 +175,7 @@ export class KubernetesProxy { } private async getClusterForRequest(req: Request): Promise { - const clusterName = req.header(HEADER_KUBERNETES_CLUSTER); + const clusterName = req.headers[HEADER_KUBERNETES_CLUSTER.toLowerCase()]; const clusters = await this.clusterSupplier.getClusters(); if (!clusters || clusters.length <= 0) {