Skip to content

Commit

Permalink
fix(jmx): 'Copy Jolokia URL' in JMX Operations tab should provide ful…
Browse files Browse the repository at this point in the history
…l path including host origin
  • Loading branch information
tadayosi committed Oct 23, 2023
1 parent 073018b commit b08c41e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ module.exports = {
devServer.app.get('/hawtio/keycloak/client-config', (_, res) => res.send(JSON.stringify(keycloakClientConfig)))
devServer.app.get('/hawtio/keycloak/validate-subject-matches', (_, res) => res.send('true'))

middlewares.push({
// Hawtio backend middleware should be run before other middlewares (thus 'unshift')
// in order to handle GET requests to the proxied Jolokia endpoint.
middlewares.unshift({
name: 'hawtio-backend',
path: '/hawtio/proxy',
middleware: hawtioBackend({
Expand Down
2 changes: 1 addition & 1 deletion packages/hawtio/src/plugins/shared/connect-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class ConnectService implements IConnectService {

connect(connection: Connection) {
log.debug('Connecting with options:', toString(connection))
const basepath = hawtio.getBasePath() || '/'
const basepath = hawtio.getBasePath() ?? '/'
const url = `${basepath}?${PARAM_KEY_CONNECTION}=${connection.name}`
log.debug('Opening URL:', url)
window.open(url)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hawtio } from '@hawtiosrc/core'
import { jolokiaService } from '@hawtiosrc/plugins/shared/jolokia-service'
import { escapeMBean } from '@hawtiosrc/util/jolokia'
import { log } from '../globals'
Expand All @@ -9,9 +10,12 @@ class OperationService {
}

async getJolokiaUrl(mbean: string, operation: string): Promise<string> {
//Ideally this would be provided by jolokia but it doesn't expose that API yet
const mbeanName = escapeMBean(mbean)
return `${await jolokiaService.getJolokiaUrl()}/exec/${mbeanName}/${operation}`
const basePath = hawtio.getBasePath() ?? ''
const origin = window.location.origin
const jolokiaUrl = (await jolokiaService.getJolokiaUrl()) ?? ''
const jolokiaPath = jolokiaUrl.startsWith('/') ? jolokiaUrl : basePath + jolokiaUrl
return `${origin}${jolokiaPath}/exec/${mbeanName}/${operation}`
}
}

Expand Down

0 comments on commit b08c41e

Please sign in to comment.