From add08e363ad2e77bd88ad02e910e1f986c617b0d Mon Sep 17 00:00:00 2001 From: Replit Agent Date: Thu, 19 Mar 2026 13:59:57 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20use=20process.cwd()=20for=20tower=20path?= =?UTF-8?q?=20=E2=80=94=20import.meta.url=20is=20undefined=20in=20CJS=20bu?= =?UTF-8?q?ndle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- artifacts/api-server/src/app.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/artifacts/api-server/src/app.ts b/artifacts/api-server/src/app.ts index bb41038..96dbb90 100644 --- a/artifacts/api-server/src/app.ts +++ b/artifacts/api-server/src/app.ts @@ -1,12 +1,9 @@ import express, { type Express } from "express"; import cors from "cors"; import path from "path"; -import { fileURLToPath } from "url"; import router from "./routes/index.js"; import { responseTimeMiddleware } from "./middlewares/response-time.js"; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - const app: Express = express(); app.set("trust proxy", 1); @@ -50,11 +47,9 @@ app.use(responseTimeMiddleware); app.use("/api", router); // ── Tower (Matrix 3D frontend) ─────────────────────────────────────────────── -// Serve the pre-built Three.js world at /tower. The Matrix's WebSocket client -// auto-connects to /api/ws on the same host. -// __dirname resolves to artifacts/api-server/dist/ at runtime. -// Go up three levels to reach workspace root, then into the-matrix/dist. -const towerDist = path.join(__dirname, "..", "..", "..", "the-matrix", "dist"); +// Serve the pre-built Three.js world at /tower. WS client auto-connects to +// /api/ws on the same host. process.cwd() = workspace root at runtime. +const towerDist = path.resolve(process.cwd(), "the-matrix", "dist"); app.use("/tower", express.static(towerDist)); app.get("/tower/*splat", (_req, res) => res.sendFile(path.join(towerDist, "index.html")));