1
0

♻️ Use express.static

This commit is contained in:
2021-06-16 17:21:37 +02:00
parent 9fa4de3f47
commit c1a316d7e4

View File

@@ -347,6 +347,7 @@ async function stealVip(msg: {channelId: string; userDisplayName: string; messag
/* /*
Webserver Webserver
*/ */
app.use(express.static(path.join(__dirname, "client")));
const server = app.listen(!DEV_MODE ? 8080 : 8081, '0.0.0.0'); const server = app.listen(!DEV_MODE ? 8080 : 8081, '0.0.0.0');
server.on("listening", () => { server.on("listening", () => {
@@ -358,17 +359,3 @@ server.on("upgrade", (req, socket, head) => {
wsServer.emit("connection", socket, req); wsServer.emit("connection", socket, req);
}); });
}); });
app.get("*", async (req, res) => {
try {
let rpath = req.path;
if (rpath.endsWith("/")) {
rpath += "index.html";
}
res.sendFile(path.join(process.cwd(), "client", rpath));
} catch (e) {
res.sendStatus(404);
}
});