mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
use always random subdomain for getResponse
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
827571b948
commit
a9227bd02e
@ -3,7 +3,7 @@
|
|||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import { EventEmitter } from "../../common/event-emitter";
|
import { EventEmitter } from "../../common/event-emitter";
|
||||||
import { cancelableFetch } from "../utils/cancelableFetch";
|
import { cancelableFetch } from "../utils/cancelableFetch";
|
||||||
|
import { randomBytes } from "crypto";
|
||||||
export interface JsonApiData {
|
export interface JsonApiData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,10 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
||||||
}
|
}
|
||||||
|
|
||||||
getResponse(reqUrl: string, params?: P, init: RequestInit = { }): Promise<Response> {
|
getResponse(path: string, params?: P, init: RequestInit = {}): Promise<Response> {
|
||||||
|
const reqPath = `${this.config.apiBase}${path}`;
|
||||||
|
const subdomain = randomBytes(2).toString("hex");
|
||||||
|
let reqUrl = `http://${subdomain}.${window.location.host}${reqPath}`; // hack around browser connection limits (chromium allows 6 per domain)
|
||||||
const reqInit: RequestInit = { ...init };
|
const reqInit: RequestInit = { ...init };
|
||||||
const { query } = params || {} as P;
|
const { query } = params || {} as P;
|
||||||
|
|
||||||
@ -70,8 +73,8 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const infoLog: JsonApiLog = {
|
const infoLog: JsonApiLog = {
|
||||||
method: `${reqInit.method.toUpperCase()} (stream)`,
|
method: reqInit.method.toUpperCase(),
|
||||||
reqUrl,
|
reqUrl: reqPath,
|
||||||
reqInit,
|
reqInit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -372,8 +372,7 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
}
|
}
|
||||||
const { abortController, namespace, callback } = opts;
|
const { abortController, namespace, callback } = opts;
|
||||||
|
|
||||||
// FIXME
|
const watchUrl = this.getWatchUrl(namespace);
|
||||||
const watchUrl = `http://${this.kind}-watch.${window.location.host}${apiKubePrefix}${this.getWatchUrl(namespace)}`;
|
|
||||||
const responsePromise = this.request.getResponse(watchUrl, null, {
|
const responsePromise = this.request.getResponse(watchUrl, null, {
|
||||||
signal: abortController.signal
|
signal: abortController.signal
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user