mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
(fix): More general address calculation
This commit is contained in:
parent
b57d6b305a
commit
ffade5fb8e
@ -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',
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -222,15 +222,7 @@ module.exports = function (configLocation, viteProxy) {
|
||||
})
|
||||
);
|
||||
|
||||
if (viteProxy) {
|
||||
app.use(
|
||||
"/vite",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://localhost:8080/`,
|
||||
ws: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
app.use(bodyParser.json({ limit: "50mb" }));
|
||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||
app.use(express.static(path.join(__dirname, "..", "public")));
|
||||
@ -242,19 +234,23 @@ module.exports = function (configLocation, viteProxy) {
|
||||
app.use("/api/databases", databasesRouter);
|
||||
app.use("/api/speech", speechRouter);
|
||||
app.use("/resources", resourcesRouter);
|
||||
app.use("/express/api/airbases", airbasesRouter);
|
||||
app.use("/express/api/elevation", elevationRouter);
|
||||
app.use("/express/api/databases", databasesRouter);
|
||||
app.use("/express/api/speech", speechRouter);
|
||||
app.use("/express/resources", resourcesRouter);
|
||||
|
||||
/* Set default index */
|
||||
if (!viteProxy) {
|
||||
if (viteProxy) {
|
||||
app.use(
|
||||
"/vite",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://localhost:8080/`,
|
||||
ws: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
app.get("/", function (req, res) {
|
||||
res.sendfile(path.join(__dirname, "..", "public", "vite", "index.html"));
|
||||
});
|
||||
}
|
||||
|
||||
/* Start the audio backend */
|
||||
if (config["audio"]) {
|
||||
let audioBackend = new AudioBackend(
|
||||
config["audio"]["SRSPort"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user