18 lines
438 B
JavaScript
18 lines
438 B
JavaScript
import express from "express";
|
|
import path from "path";
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
// Serve static files from dist
|
|
app.use(express.static(path.join(__dirname, "dist")));
|
|
|
|
// For React Router: always return index.html
|
|
app.get("*", (req, res) => {
|
|
res.sendFile(path.join(__dirname, "dist", "index.html"));
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Server running at http://localhost:${PORT}`);
|
|
});
|