From d76549f94a4df193af9483f6c47d2a359c8c6f2b Mon Sep 17 00:00:00 2001 From: Asep Haryana Saputra <90584806+MythEclipse@users.noreply.github.com> Date: Thu, 21 May 2026 12:35:28 +0000 Subject: [PATCH] refactor(app): simplify path handling for static files and index.html --- src/http/app.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/http/app.ts b/src/http/app.ts index 3e5bb40..e869098 100644 --- a/src/http/app.ts +++ b/src/http/app.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; -import { fileURLToPath } from "node:url"; import type { Client } from "discord.js-selfbot-v13"; import express, { type NextFunction, @@ -23,8 +22,8 @@ import type { SharedUIStatePatch } from "../state/uiState.js"; import type { VoiceController } from "../voiceController.js"; import { createHealthRoutes } from "./health.js"; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const publicDir = path.resolve(process.cwd(), "public"); +const reactAppDir = path.join(publicDir, "app"); type Logger = ReturnType; @@ -72,11 +71,11 @@ export function createHttpApp(options: CreateHttpAppOptions) { }); app.use(express.json()); - app.use(express.static(path.join(__dirname, "../../public"))); - app.use(express.static(path.join(__dirname, "../../public/app"))); + app.use(express.static(publicDir)); + app.use(express.static(reactAppDir)); app.get("/", (_req: Request, res: Response) => { - const reactIndex = path.join(__dirname, "../../public/app/index.html"); + const reactIndex = path.join(reactAppDir, "index.html"); if (fs.existsSync(reactIndex)) { res.sendFile(reactIndex); return;