(fix): More general address calculation

This commit is contained in:
Davide Passoni
2024-12-06 17:09:57 +01:00
parent b57d6b305a
commit ffade5fb8e
4 changed files with 23 additions and 23 deletions

View File

@@ -106,11 +106,15 @@ export class OlympusApp {
}
getExpressAddress() {
return `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}express`;
let address = `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}`;
if (address[address.length - 1] !== "/") address += "/"
return address;
}
getBackendAddress() {
return `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}olympus`;
let address = `${window.location.href.split("?")[0].replace("vite/", "").replace("vite", "")}`;
if (address[address.length - 1] !== "/") address += "/"
return address + "olympus"
}
start() {
@@ -153,7 +157,7 @@ export class OlympusApp {
});
/* Load the config file from the server */
const configRequest = new Request(this.getExpressAddress() + "/resources/config", {
const configRequest = new Request(this.getExpressAddress() + "resources/config", {
headers: {
'Cache-Control': 'no-cache',
}

View File

@@ -164,7 +164,7 @@ export class ServerManager {
getConfig(callback: CallableFunction) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", getApp().getExpressAddress() + "/config", true);
xmlHttp.open("GET", getApp().getExpressAddress() + "config", true);
xmlHttp.onload = function (e) {
var data = JSON.parse(xmlHttp.responseText);
callback(data);

View File

@@ -48,10 +48,10 @@ export class UnitsManager {
constructor() {
this.#unitDatabase = new UnitDatabase();
this.#unitDatabase.load(getApp().getExpressAddress() + "/api/databases/units/aircraftdatabase", "aircraft");
this.#unitDatabase.load(getApp().getExpressAddress() + "/api/databases/units/helicopterdatabase", "helicopter");
this.#unitDatabase.load(getApp().getExpressAddress() + "/api/databases/units/groundunitdatabase", "groundunit");
this.#unitDatabase.load(getApp().getExpressAddress() + "/api/databases/units/navyunitdatabase", "navyunit");
this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/aircraftdatabase", "aircraft");
this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/helicopterdatabase", "helicopter");
this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/groundunitdatabase", "groundunit");
this.#unitDatabase.load(getApp().getExpressAddress() + "api/databases/units/navyunitdatabase", "navyunit");
CommandModeOptionsChangedEvent.on(() => {
Object.values(this.#units).forEach((unit: Unit) => unit.updateVisibility());