fixed server

This commit is contained in:
2026-01-29 05:55:49 -08:00
parent ce9bd20040
commit f428af0d35
+9 -3
View File
@@ -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"));
});