From 3076597628172b34b89baba3c0f3edc80899d8fa Mon Sep 17 00:00:00 2001 From: Chewbaccalakis Date: Sun, 8 Mar 2026 15:11:52 -0700 Subject: [PATCH] server.js --- server.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 server.js diff --git a/server.js b/server.js new file mode 100644 index 0000000..7c1f93d --- /dev/null +++ b/server.js @@ -0,0 +1,23 @@ +// server.js +import express from "express"; +import path from "path"; +import { fileURLToPath } from "url"; + +const app = express(); +const PORT = process.env.PORT || 3001; + +// 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"))); + +// React Router fallback: send index.html for any unmatched route +app.get(/.*/, (req, res) => { + res.sendFile(path.join(__dirname, "dist", "index.html")); +}); + +app.listen(PORT, () => { + console.log(`Server running at http://localhost:${PORT}`); +});