Skip to content

Commit

Permalink
backend(23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibiing committed Dec 18, 2024
1 parent d045503 commit a58fc69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});
Expand Down

0 comments on commit a58fc69

Please sign in to comment.