Skip to content

Commit

Permalink
fix(connect): better handling of preset-connections path
Browse files Browse the repository at this point in the history
  • Loading branch information
tadayosi committed Jan 8, 2025
1 parent 2915289 commit 39ed52d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/hawtio/src/plugins/shared/connect-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -137,7 +137,8 @@ class ConnectService implements IConnectService {
*/
private async loadPresetConnections(): Promise<void> {
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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 39ed52d

Please sign in to comment.