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) {