mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-09-25 22:04:40 +00:00
express 404
This commit is contained in:
+8
-6
@@ -27,7 +27,7 @@ async function getDirectories(path: string): Promise<dirtype> {
|
||||
}
|
||||
|
||||
let dirs: dirtype | undefined = undefined;
|
||||
async function combinePath(path: string, tryAgain = true): Promise<string> {
|
||||
async function combinePath(path: string, tryAgain = true, reqpath: string): Promise<string> {
|
||||
if (!dirs) {
|
||||
dirs = await getDirectories(__dirname);
|
||||
}
|
||||
@@ -48,18 +48,20 @@ async function combinePath(path: string, tryAgain = true): Promise<string> {
|
||||
}
|
||||
if (find(pathDir, dirs)) {
|
||||
return __dirname + path;
|
||||
} else if (reqpath.startsWith("/channels")) {
|
||||
return __dirname + "/webpage/app.html";
|
||||
} else {
|
||||
if (!path.includes(".")) {
|
||||
const str = await combinePath(path + ".html", false);
|
||||
if (str !== __dirname + "/webpage/app.html") {
|
||||
const str = await combinePath(path + ".html", false, reqpath);
|
||||
if (str !== __dirname + "/webpage/404.html") {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (devmode && tryAgain) {
|
||||
dirs = await getDirectories(__dirname);
|
||||
return combinePath(path, false);
|
||||
return combinePath(path, false, reqpath);
|
||||
}
|
||||
return __dirname + "/webpage/app.html";
|
||||
return __dirname + "/webpage/404.html";
|
||||
}
|
||||
}
|
||||
interface Instance {
|
||||
@@ -184,7 +186,7 @@ app.use("/", async (req: Request, res: Response) => {
|
||||
res.sendFile(path.join(__dirname, "webpage", "app.html"));
|
||||
return;
|
||||
}
|
||||
const filePath = await combinePath("/webpage/" + req.path);
|
||||
const filePath = await combinePath("/webpage/" + req.path, true, req.path);
|
||||
res.sendFile(filePath);
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</head>
|
||||
<body class="no-theme">
|
||||
<div class="errorHTML">
|
||||
<img src="./logo.svg" with="128" height="128" />
|
||||
<img src="/logo.svg" with="128" height="128" />
|
||||
<div>
|
||||
<h1 i18n="404.title">It seems you're lost</h1>
|
||||
<h3 i18n="404.404">404 Page Not Found</h3>
|
||||
|
||||
Reference in New Issue
Block a user