From c0197cd610ff6b6c014f26fcd4d852f1c01b40d7 Mon Sep 17 00:00:00 2001 From: Nadim Ritter Date: Wed, 28 Aug 2024 10:36:14 +0200 Subject: [PATCH] new approach --- server/src/app.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/src/app.ts b/server/src/app.ts index a73d344..e145514 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -27,22 +27,21 @@ if (ENV.NODE_ENV === "dev") { app.use(apiRequestLogger); // Static files config with dynamic base path -const basePath = ENV.BASE_PATH || "/"; -app.use(basePath, express.static(path)); +app.use(ENV.BASE_PATH, express.static(path)); app.use(bodyParser.json()); // API routes -app.use(basePath, authorizationRoutes); -app.use(basePath, routes); +app.use(authorizationRoutes); +app.use(routes); // Static files route with dynamic base path -app.get(basePath + "/", (req: Request, res: Response) => { +app.get(ENV.BASE_PATH + "/", (req: Request, res: Response) => { console.log("Serving main index at:", mainIndexPath); res.sendFile(mainIndexPath); }); // Catch-all route to handle all other requests -app.get(basePath + "/*", (req: Request, res: Response) => { +app.get(ENV.BASE_PATH + "/*", (req: Request, res: Response) => { console.log("Catch-all route, serving main index at:", mainIndexPath); res.sendFile(mainIndexPath); });