32 lines
806 B
TypeScript
Raw Normal View History

2024-05-04 14:44:23 +02:00
import express from "express";
import path from "path";
const webuiRouter = express.Router();
const rootDir = path.join(__dirname, "../..");
2024-05-04 14:44:23 +02:00
// Redirect / to /webui/
2024-05-04 14:44:23 +02:00
webuiRouter.get("/", (_req, res) => {
res.redirect("/webui/");
});
// Redirect /webui to /webui/
webuiRouter.use("/webui", (req, res, next) => {
if (req.originalUrl === "/") {
return res.redirect("/webui/");
2024-05-04 14:44:23 +02:00
}
next();
2024-05-04 14:44:23 +02:00
});
// Serve virtual routes
webuiRouter.get("/webui/inventory", (_req, res) => {
res.sendFile(path.join(rootDir, "static/webui/index.html"));
});
webuiRouter.get("/webui/mods", (_req, res) => {
res.sendFile(path.join(rootDir, "static/webui/index.html"));
});
// Serve static files
webuiRouter.use("/webui", express.static(path.join(rootDir, "static/webui")));
2024-05-04 14:44:23 +02:00
export { webuiRouter };