diff --git a/openwisp_network_topology/templates/netjsongraph/netjsongraph-script.html b/openwisp_network_topology/templates/netjsongraph/netjsongraph-script.html index 2fcbdea..c2ab4b2 100644 --- a/openwisp_network_topology/templates/netjsongraph/netjsongraph-script.html +++ b/openwisp_network_topology/templates/netjsongraph/netjsongraph-script.html @@ -4,7 +4,8 @@ loadNetJsonGraph = (el='body', url='{{ graph_url }}?include_unpublished=true') => { const history_url = '{{ history_url }}?include_unpublished=true'; const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsUrl = `${wsProtocol}//${window.location.host}/ws/network-topology/topology/${getTopologyIdFromUrl()}/`; + const apiHost = new URL('{{ graph_url }}').host; + const wsUrl = `${wsProtocol}//${apiHost}/ws/network-topology/topology/${getTopologyIdFromUrl()}/`; const socket = new WebSocket(wsUrl); const getDataParseOptions = (data) => {