mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Serve statics using webpack-dev-server instead of lens-proxy, redirect request of Lens.html/Lens.js to webpack-dev-server
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
parent
4d7bfe4f33
commit
79abfe49d9
@ -94,9 +94,16 @@ export class Router {
|
|||||||
return mimeTypes[path.extname(filename).slice(1)] || "text/plain"
|
return mimeTypes[path.extname(filename).slice(1)] || "text/plain"
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleStaticFile(filePath: string, res: http.ServerResponse) {
|
async handleStaticFile(filePath: string, res: http.ServerResponse, requestpath?: string) {
|
||||||
const asset = path.join(__static, filePath);
|
const asset = path.join(__static, filePath);
|
||||||
try {
|
try {
|
||||||
|
if (path.basename(requestpath).includes(appName)) {
|
||||||
|
res.writeHead(307,
|
||||||
|
{ Location: 'http://localhost:9000' + requestpath }
|
||||||
|
);
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const data = await readFile(asset);
|
const data = await readFile(asset);
|
||||||
res.setHeader("Content-Type", this.getMimeType(asset));
|
res.setHeader("Content-Type", this.getMimeType(asset));
|
||||||
res.write(data)
|
res.write(data)
|
||||||
@ -108,8 +115,8 @@ export class Router {
|
|||||||
|
|
||||||
protected addRoutes() {
|
protected addRoutes() {
|
||||||
// Static assets
|
// Static assets
|
||||||
this.router.add({ method: 'get', path: '/{path*}' }, ({ params, response }: LensApiRequest) => {
|
this.router.add({ method: 'get', path: '/{path*}' }, ({ params, response, path }: LensApiRequest) => {
|
||||||
this.handleStaticFile(params.path, response);
|
this.handleStaticFile(params.path, response, path);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.add({ method: "get", path: `${apiPrefix}/kubeconfig/service-account/{namespace}/{account}` }, kubeconfigRoute.routeServiceAccountRoute.bind(kubeconfigRoute))
|
this.router.add({ method: "get", path: `${apiPrefix}/kubeconfig/service-account/{namespace}/{account}` }, kubeconfigRoute.routeServiceAccountRoute.bind(kubeconfigRoute))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user