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
*/
app.use(express.static(path.join(__dirname, "client")));
const server = app.listen(!DEV_MODE ? 8080 : 8081, '0.0.0.0');
server.on("listening", () => {
@@ -357,18 +358,4 @@ server.on("upgrade", (req, socket, head) => {
wsServer.handleUpgrade(req, socket, head, socket => {
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);
}
});