2024-05-04 14:44:23 +02:00
|
|
|
import express from "express";
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
const webuiRouter = express.Router();
|
|
|
|
|
2024-05-16 01:31:14 +02:00
|
|
|
// Redirect / to /webui/
|
2024-05-04 14:44:23 +02:00
|
|
|
webuiRouter.get("/", (_req, res) => {
|
|
|
|
res.redirect("/webui/");
|
|
|
|
});
|
|
|
|
|
2024-05-16 01:31:14 +02:00
|
|
|
// 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
|
|
|
}
|
2024-05-16 01:31:14 +02:00
|
|
|
next();
|
2024-05-04 14:44:23 +02:00
|
|
|
});
|
|
|
|
|
2024-05-16 01:31:14 +02:00
|
|
|
// Serve static files from the webui directory
|
|
|
|
webuiRouter.use("/webui", express.static(path.join(__dirname, "../..", "static/webui")));
|
2024-05-04 14:44:23 +02:00
|
|
|
|
|
|
|
export { webuiRouter };
|