Skip to content

Commit

Permalink
Merge pull request #604 from FlowFuse/563-ctrlx-core
Browse files Browse the repository at this point in the history
More robust path replacement to account for proxy & httpNodeRoot configs
  • Loading branch information
joepavitt authored Feb 23, 2024
2 parents 126e843 + 0f4ded9 commit 1e78708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 3 additions & 4 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ export default {
Object.values(payload.pages).forEach(page => {
// check that the page's bound UI is also in our config
if (payload.dashboards[page.ui]) {
const ui = payload.dashboards[page.ui]
// re-write base path in case of proxy
ui.path = this.setup.basePath
// const ui = payload.dashboards[page.ui]
// re-write base path in case of proxy & httpNodeRoot
const route = (this.setup.basePath + page.path).replace(/\/\//g, '/')
const route = (ui.root + ui.path + page.path).replace(/\/\//g, '/')
const routeName = 'Page:' + page.name
this.$router?.addRoute({
path: route,
Expand Down
6 changes: 4 additions & 2 deletions ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ fetch('_setup')
setup.basePath = basePath

if (setup.socketio?.path) {
// TODO: be better here, rather than depend on /dashboard
setup.socketio.path = setup.socketio.path.replace('/dashboard', basePath)
// get text before /socket.io and replace it with the calculated basePath
// basePath would have taken into account any proxy and/or httpNodeRoot settings
const replace = setup.socketio.path.split('/socket.io')[0]
setup.socketio.path = setup.socketio.path.replace(replace, basePath)
}

store.commit('setup/set', setup)
Expand Down

0 comments on commit 1e78708

Please sign in to comment.