diff --git a/src/common/register-static.ts b/src/common/register-static.ts index 445b5e973d..0157d7785d 100644 --- a/src/common/register-static.ts +++ b/src/common/register-static.ts @@ -3,7 +3,7 @@ import path from "path"; import { protocol } from "electron" import logger from "../main/logger"; -import { staticDir, staticProto } from "./vars"; +import { staticDir, staticProto, outDir } from "./vars"; export function registerStaticProtocol(rootFolder = staticDir) { const scheme = staticProto.replace("://", ""); @@ -23,3 +23,7 @@ export function getStaticUrl(filePath: string) { export function getStaticPath(filePath: string) { return path.resolve(staticDir, filePath); } + +export function getOutPath(filePath: string) { + return path.resolve(outDir, filePath); +} diff --git a/src/main/context-handler.ts b/src/main/context-handler.ts index b85a537603..137d45cb0f 100644 --- a/src/main/context-handler.ts +++ b/src/main/context-handler.ts @@ -8,9 +8,6 @@ import { KubeAuthProxy } from "./kube-auth-proxy" import { Cluster, ClusterPreferences } from "./cluster" import { prometheusProviders } from "../common/prometheus-providers" import { PrometheusProvider, PrometheusService } from "./prometheus/provider-registry" -import { reactAppName } from "../common/vars" -import path from "path" -import { format as formatUrl } from "url" export class ContextHandler { public contextName: string @@ -59,12 +56,7 @@ export class ContextHandler { this.clusterUrl = url.parse(kc.getCurrentCluster().server) this.contextName = kc.currentContext; this.defaultNamespace = kc.getContextObject(kc.currentContext).namespace - //this.url = `http://${this.id}.localhost:${cluster.port}/` - this.url = formatUrl({ - pathname: path.join(__dirname, `${reactAppName}.html`), - protocol: "file", - slashes: true, - }) + this.url = `http://${this.id}.localhost:${cluster.port}/` this.kubernetesApi = `http://127.0.0.1:${cluster.port}/${this.id}` this.kc.clusters = [ { diff --git a/src/main/router.ts b/src/main/router.ts index 46c342b70f..91219de7b2 100644 --- a/src/main/router.ts +++ b/src/main/router.ts @@ -9,7 +9,7 @@ import { kubeconfigRoute } from "./routes/kubeconfig" import { metricsRoute } from "./routes/metrics" import { watchRoute } from "./routes/watch" import { portForwardRoute } from "./routes/port-forward" -import { getStaticPath } from "../common/register-static"; +import { getOutPath } from "../common/register-static"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Call = require('@hapi/call'); @@ -86,11 +86,11 @@ export class Router { } protected handleStaticFile(filePath: string, response: http.ServerResponse) { - const asset = getStaticPath(filePath); + const asset = getOutPath(filePath); readFile(asset, (err, data) => { if (err) { // default to index.html so that react routes work when page is refreshed - this.handleStaticFile("index.html", response) + this.handleStaticFile("app_react.html", response) } else { const type = mimeTypes[path.extname(asset).slice(1)] || "text/plain"; response.setHeader("Content-Type", type);