Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jmx): 'Copy Jolokia URL' in JMX Operations tab should provide full path including host origin #629

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading