Enable csp on lens proxy (#5581)

* enable csp on lens proxy

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* move csp default value to package.json

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2022-06-09 13:39:37 +03:00
1 parent 2b5d54e8d9
commit 240dfad167
3 files changed
+8 -2

No files matched your search

+1
View File
@@ -143,3 +143,4 @@ export const appSemVer = new SemVer(packageInfo.version);
export const docsUrl = "https://docs.k8slens.dev/main/" as string;
export const sentryDsn = packageInfo.config?.sentryDsn ?? "";
export const contentSecurityPolicy = packageInfo.config?.contentSecurityPolicy ?? "";
+5 -1
View File
@@ -7,7 +7,7 @@ import net from "net";
import type http from "http";
import spdy from "spdy";
import type httpProxy from "http-proxy";
import { apiPrefix, apiKubePrefix } from "../../common/vars";
import { apiPrefix, apiKubePrefix, contentSecurityPolicy } from "../../common/vars";
import type { Router } from "../router/router";
import type { ClusterContextHandler } from "../context-handler/context-handler";
import logger from "../logger";
@@ -239,6 +239,10 @@ export class LensProxy {
}
}
if (contentSecurityPolicy) {
res.setHeader("Content-Security-Policy", contentSecurityPolicy);
}
this.dependencies.router.route(cluster, req, res);
}
}