diff --git a/front/appEventsCore.php b/front/appEventsCore.php index 9e328db9..473d83f6 100755 --- a/front/appEventsCore.php +++ b/front/appEventsCore.php @@ -23,11 +23,9 @@ showSpinner() $(document).ready(function () { - const protocol = window.location.protocol.replace(':', ''); - const host = window.location.hostname; const apiToken = getSetting("API_TOKEN"); - const port = getSetting("GRAPHQL_PORT"); - const graphqlUrl = `${protocol}://${host}:${port}/graphql`; + const apiBase = getApiBase(); + const graphqlUrl = `${apiBase}/graphql`; $('#appevents-table').DataTable({ processing: true, diff --git a/front/events.php b/front/events.php index 8df16c1b..a0c9b6a8 100755 --- a/front/events.php +++ b/front/events.php @@ -160,11 +160,10 @@ function periodChanged() { function getEventsTotals() { stopTimerRefreshData(); - const protocol = window.location.protocol.replace(":", ""); - const host = window.location.hostname; - const port = getSetting("GRAPHQL_PORT"); + // Build API URL + const apiBase = getApiBase(); const apiToken = getSetting("API_TOKEN"); - const url = `${protocol}://${host}:${port}/sessions/totals?period=${encodeURIComponent(period)}`; + const url = `${apiBase}/sessions/totals?period=${encodeURIComponent(period)}`; $.ajax({ url, @@ -207,11 +206,9 @@ function getEvents(type) { table.column(7).visible(config.sesionCols); // Build API URL - const protocol = window.location.protocol.replace(":", ""); - const host = window.location.hostname; - const port = getSetting("GRAPHQL_PORT"); + const apiBase = getApiBase(); const apiToken = getSetting("API_TOKEN"); - const url = `${protocol}://${host}:${port}/sessions/session-events?type=${encodeURIComponent(type)}&period=${encodeURIComponent(period)}`; + const url = `${apiBase}/sessions/session-events?type=${encodeURIComponent(type)}&period=${encodeURIComponent(period)}`; table.clear().draw(); // Clear old rows