mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
fix: Audio backend working if both port and endpoint added
Added ability to use uri for backend address (remote debugging)
This commit is contained in:
@@ -126,9 +126,13 @@ module.exports = function (configLocation, viteProxy) {
|
||||
});
|
||||
|
||||
/* Define middleware */
|
||||
app.use(logger('dev', {
|
||||
skip: function (req, res) { return res.statusCode < 400 }
|
||||
}));
|
||||
app.use(
|
||||
logger("dev", {
|
||||
skip: function (req, res) {
|
||||
return res.statusCode < 400;
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
/* Authorization middleware */
|
||||
if (
|
||||
@@ -166,7 +170,7 @@ module.exports = function (configLocation, viteProxy) {
|
||||
app.use("/olympus", async (req, res, next) => {
|
||||
/* Check if custom authorization headers are being used */
|
||||
const user =
|
||||
//@ts-ignore
|
||||
//@ts-ignore
|
||||
req.auth?.user ??
|
||||
checkCustomHeaders(config, usersConfig, groupsConfig, req);
|
||||
|
||||
@@ -221,16 +225,27 @@ module.exports = function (configLocation, viteProxy) {
|
||||
});
|
||||
|
||||
/* Proxy middleware */
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}:${config["backend"]["port"]}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
|
||||
if (config["backend"]["port"]) {
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `http://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}:${config["backend"]["port"]}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
app.use(
|
||||
"/olympus",
|
||||
httpProxyMiddleware.createProxyMiddleware({
|
||||
target: `https://${
|
||||
backendAddress === "*" ? "localhost" : backendAddress
|
||||
}/olympus`,
|
||||
changeOrigin: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
app.use(bodyParser.json({ limit: "50mb" }));
|
||||
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
|
||||
|
||||
@@ -45,29 +45,44 @@ module.exports = function (configLocation) {
|
||||
router.put("/config", function (req, res, next) {
|
||||
if (req.auth?.user === "Admin") {
|
||||
/* Create a backup folder for the configuration files */
|
||||
let backupFolder = path.join(path.dirname(configLocation), "Olympus Configs Backup");
|
||||
let backupFolder = path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup"
|
||||
);
|
||||
if (!fs.existsSync(backupFolder)) {
|
||||
fs.mkdirSync(backupFolder);
|
||||
}
|
||||
|
||||
/* Make a backup of the existing files */
|
||||
let timestamp = new Date().toISOString().replace(/:/g, "-");
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusUsers.json." + timestamp
|
||||
if (
|
||||
fs.existsSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json")
|
||||
)
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusGroups.json." + timestamp
|
||||
) {
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusUsers.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusUsers.json." + timestamp
|
||||
)
|
||||
);
|
||||
}
|
||||
if (
|
||||
fs.existsSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json")
|
||||
)
|
||||
);
|
||||
) {
|
||||
fs.copyFileSync(
|
||||
path.join(path.dirname(configLocation), "olympusGroups.json"),
|
||||
path.join(
|
||||
path.dirname(configLocation),
|
||||
"Olympus Configs Backup",
|
||||
"olympusGroups.json." + timestamp
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/* Save the users configuration file */
|
||||
let usersConfig = req.body.users;
|
||||
|
||||
Reference in New Issue
Block a user