From 1b300e51518946650123dcc353c395c3ee5f0817 Mon Sep 17 00:00:00 2001 From: "ella.l" Date: Thu, 24 Sep 2020 22:41:50 +0900 Subject: [PATCH] Fixes #527: Allow suburl to map the application --- .../cluster-nodes/cluster-nodes.controller.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ui/src/containers/cluster-nodes/cluster-nodes.controller.js b/ui/src/containers/cluster-nodes/cluster-nodes.controller.js index 9b4d2684..da2831e6 100644 --- a/ui/src/containers/cluster-nodes/cluster-nodes.controller.js +++ b/ui/src/containers/cluster-nodes/cluster-nodes.controller.js @@ -14,20 +14,25 @@ class clusterNodesController { this.clusterName = $stateParams.clusterName; // Try to get URL - // even if path is being forwared by a Apache / Nginx conf. + // even if path is being forwarded by a Apache / Nginx conf. // i.e. http://my_site.com/my/custom/path is the root of the python app console.log('---- window.location', window.location) - let baseUrl = window.location.href.split('/#!')[0]; - if (/\:8080/.test(baseUrl)) baseUrl = 'http://localhost:5000'; + let url = `${window.location.protocol}//${window.location.host}`; + let baseUrl = window.location.pathname + // console.log('---- baseUrl: ', baseUrl) + + if (/\:8080/.test(url)) { + url = 'http://localhost:5000'; + } // Websockets do not work with relative paths, so get absolute and append the WS portion // upgrade from HTTP to WS should be automatic - // baseUrl = baseUrl += `/ws/nodes/${this.clusterName}/nodes`; - baseUrl = baseUrl += `/ws`; - // console.log('---- baseUrl: ', baseUrl) + // url = url += `/ws/nodes/${this.clusterName}/nodes`; + url = url += `/ws`; + // console.log('---- url: ', url) - this.socket = io(baseUrl); + this.socket = io(url, { path: baseUrl+"socket.io" }); this.socket.on('connect', () => { this.connected = true; this.socket.emit('join', {"room_name": this.clusterName + "::nodes"});