♻️ Use express.static
This commit is contained in:
15
index.ts
15
index.ts
@@ -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", () => {
|
||||
@@ -358,17 +359,3 @@ server.on("upgrade", (req, socket, head) => {
|
||||
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);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user