From 39ed52dcd87d26d4b4a2fdfda7b18038f4537f41 Mon Sep 17 00:00:00 2001 From: Tadayoshi Sato Date: Wed, 8 Jan 2025 13:09:32 +0900 Subject: [PATCH] fix(connect): better handling of preset-connections path --- .../hawtio/src/plugins/shared/connect-service.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/hawtio/src/plugins/shared/connect-service.ts b/packages/hawtio/src/plugins/shared/connect-service.ts index 840571cc..6f92f914 100644 --- a/packages/hawtio/src/plugins/shared/connect-service.ts +++ b/packages/hawtio/src/plugins/shared/connect-service.ts @@ -64,7 +64,7 @@ export const PARAM_KEY_CONNECTION = 'con' export const PARAM_KEY_REDIRECT = 'redirect' const PATH_LOGIN = '/connect/login' -const PATH_PRESET_CONNECTIONS = 'preset-connections' +const PATH_PRESET_CONNECTIONS = '/preset-connections' export interface IConnectService { getCurrentConnectionId(): string | null @@ -137,7 +137,8 @@ class ConnectService implements IConnectService { */ private async loadPresetConnections(): Promise { try { - const res = await fetch(PATH_PRESET_CONNECTIONS) + const path = this.getPresetConnectionsPath() + const res = await fetch(path) if (!res.ok) { log.debug('Failed to load preset connections:', res.status, res.statusText) return @@ -189,6 +190,11 @@ class ConnectService implements IConnectService { } } + private getPresetConnectionsPath(): string { + const basePath = hawtio.getBasePath() + return basePath ? `${basePath}${PATH_PRESET_CONNECTIONS}` : PATH_PRESET_CONNECTIONS + } + getCurrentConnectionId(): string | null { return this.currentConnectionId } @@ -574,7 +580,7 @@ class ConnectService implements IConnectService { getLoginPath(): string { const basePath = hawtio.getBasePath() - return `${basePath}${PATH_LOGIN}` + return basePath ? `${basePath}${PATH_LOGIN}` : PATH_LOGIN } export(connections: Connections) {