From a58fc69cac311fd92cbb4e7f3e7076f5050325a4 Mon Sep 17 00:00:00 2001 From: Bibiing Date: Wed, 18 Dec 2024 08:23:59 +0700 Subject: [PATCH] backend(23) --- server.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index d76c75a..91b3196 100644 --- a/server.js +++ b/server.js @@ -121,12 +121,15 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); if (process.env.NODE_ENV === "production") { - const distPath = path.join(__dirname, process.env.DIST_PATH || "dist"); - console.log(`dispath: ${distPath}`); + const distPath = path.join(__dirname, "dist"); + console.log(`Serving static files from: ${distPath}`); + console.log("Current directory:", __dirname); + console.log("Environment:", process.env.NODE_ENV); + console.log("Dist path:", path.join(__dirname, "dist")); // Serve static files app.use(express.static(distPath)); - // Handle React routing, return all requests to React app + // Catch-all route for SPA app.get("*", (req, res) => { res.sendFile(path.join(distPath, "index.html")); });