diff --git a/server.js b/server.js index c871457..7a00076 100644 --- a/server.js +++ b/server.js @@ -1,14 +1,20 @@ +// server.js import express from "express"; import path from "path"; +import { fileURLToPath } from "url"; const app = express(); const PORT = process.env.PORT || 3000; -// Serve static files from dist +// Fix __dirname in ES modules +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// Serve static files from Vite build app.use(express.static(path.join(__dirname, "dist"))); -// For React Router: always return index.html -app.get("*", (req, res) => { +// React Router fallback: send index.html for any unmatched route +app.get(/.*/, (req, res) => { res.sendFile(path.join(__dirname, "dist", "index.html")); });