From b97713f8cc1f0a13c3d2d09487999f329d247b54 Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 12 Nov 2024 16:56:51 +0100 Subject: [PATCH] Fixed error in express address --- frontend/react/src/mission/missionmanager.ts | 2 +- frontend/react/src/olympusapp.ts | 4 ++-- frontend/react/src/other/utils.ts | 3 ++- frontend/react/src/server/servermanager.ts | 4 ++-- frontend/react/src/unit/unitsmanager.ts | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/frontend/react/src/mission/missionmanager.ts b/frontend/react/src/mission/missionmanager.ts index 94723055..977ccd3a 100644 --- a/frontend/react/src/mission/missionmanager.ts +++ b/frontend/react/src/mission/missionmanager.ts @@ -248,7 +248,7 @@ export class MissionManager { } var xhr = new XMLHttpRequest(); - xhr.open("GET", getApp().getExpressAddress() + `api/airbases/${this.#theatre.toLowerCase()}/${callsign}`, true); + xhr.open("GET", getApp().getExpressAddress() + `/api/airbases/${this.#theatre.toLowerCase()}/${callsign}`, true); xhr.responseType = "json"; xhr.onload = () => { var status = xhr.status; diff --git a/frontend/react/src/olympusapp.ts b/frontend/react/src/olympusapp.ts index 3b621ff8..2dd70fe7 100644 --- a/frontend/react/src/olympusapp.ts +++ b/frontend/react/src/olympusapp.ts @@ -136,7 +136,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"); fetch(configRequest) .then((response) => { if (response.status === 200) { @@ -172,7 +172,7 @@ export class OlympusApp { body: JSON.stringify(profile), // Send the data in JSON format }; - fetch(this.getExpressAddress() + `resources/profile/${this.#profileName}`, requestOptions) + fetch(this.getExpressAddress() + `/resources/profile/${this.#profileName}`, requestOptions) .then((response) => { if (response.status === 200) { console.log(`Profile ${this.#profileName} saved correctly`); diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index 74539948..a7c59275 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -6,6 +6,7 @@ import { DateAndTime, UnitBlueprint } from "../interfaces"; import { Converter } from "usng"; import { MGRS } from "../types/types"; import { featureCollection } from "turf"; +import { getApp } from "../olympusapp"; export function bearing(lat1: number, lon1: number, lat2: number, lon2: number) { const φ1 = deg2rad(lat1); // φ, λ in radians @@ -291,7 +292,7 @@ export function convertDateAndTimeToDate(dateAndTime: DateAndTime) { export function getGroundElevation(latlng: LatLng, callback: CallableFunction) { /* Get the ground elevation from the server endpoint */ const xhr = new XMLHttpRequest(); - xhr.open("GET", getApp().getExpressAddress() + `api/elevation/${latlng.lat}/${latlng.lng}`, true); + xhr.open("GET", getApp().getExpressAddress() + `/api/elevation/${latlng.lat}/${latlng.lng}`, true); xhr.timeout = 500; // ms xhr.responseType = "json"; xhr.onload = () => { diff --git a/frontend/react/src/server/servermanager.ts b/frontend/react/src/server/servermanager.ts index 6ceb7c16..c7fd83bd 100644 --- a/frontend/react/src/server/servermanager.ts +++ b/frontend/react/src/server/servermanager.ts @@ -138,7 +138,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); @@ -150,7 +150,7 @@ export class ServerManager { } setAddress(address: string) { - this.#REST_ADDRESS = `${address.replace("vite/", "").replace("vite", "")}olympus`; + this.#REST_ADDRESS = address; console.log(`Setting REST address to ${this.#REST_ADDRESS}`); } diff --git a/frontend/react/src/unit/unitsmanager.ts b/frontend/react/src/unit/unitsmanager.ts index 7cc89696..d7c47fc1 100644 --- a/frontend/react/src/unit/unitsmanager.ts +++ b/frontend/react/src/unit/unitsmanager.ts @@ -56,10 +56,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());