From c1a316d7e4623b685fb835a2acffd383710980ca Mon Sep 17 00:00:00 2001 From: alexbcberio Date: Wed, 16 Jun 2021 17:21:37 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20express.static?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/index.ts b/index.ts index cc44915..2f79ae0 100644 --- a/index.ts +++ b/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", () => { @@ -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); - } }); \ No newline at end of file