Fixed entry route not redirecting correctly when the status entry page changes slug.

This commit is contained in:
George Tsomlektsis 2022-10-03 17:48:34 +03:00
parent 25ea99a436
commit b0d6b5b13d

View File

@ -155,7 +155,9 @@ let needSetup = false;
Database.init(args); Database.init(args);
await initDatabase(testMode); await initDatabase(testMode);
exports.entryPage = await setting("entryPage"); const entryPage = (await getSettings("general"))["entryPage"];
exports.entryPage = entryPage;
UptimeKumaServer.getInstance().entryPage = entryPage;
await StatusPage.loadDomainMappingList(); await StatusPage.loadDomainMappingList();
log.info("server", "Adding route"); log.info("server", "Adding route");
@ -176,14 +178,15 @@ let needSetup = false;
log.debug("entry", `Request Domain: ${hostname}`); log.debug("entry", `Request Domain: ${hostname}`);
const uptimeKumaEntryPage=UptimeKumaServer.getInstance().entryPage;
if (hostname in StatusPage.domainMappingList) { if (hostname in StatusPage.domainMappingList) {
log.debug("entry", "This is a status page domain"); log.debug("entry", "This is a status page domain");
let slug = StatusPage.domainMappingList[hostname]; let slug = StatusPage.domainMappingList[hostname];
await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug); await StatusPage.handleStatusPageResponse(response, server.indexHTML, slug);
} else if (exports.entryPage && exports.entryPage.startsWith("statusPage-")) { } else if (uptimeKumaEntryPage && uptimeKumaEntryPage.startsWith('statusPage-')) {
response.redirect("/status/" + exports.entryPage.replace("statusPage-", "")); response.redirect("/status/" + uptimeKumaEntryPage.replace("statusPage-", ""));
} else { } else {
response.redirect("/dashboard"); response.redirect("/dashboard");
@ -1085,6 +1088,7 @@ let needSetup = false;
await setSettings("general", data); await setSettings("general", data);
exports.entryPage = data.entryPage; exports.entryPage = data.entryPage;
UptimeKumaServer.getInstance().entryPage = data.entryPage;
callback({ callback({
ok: true, ok: true,