25 lines
594 B
JavaScript
25 lines
594 B
JavaScript
import express from "express";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const app = express();
|
|
const port = process.env.PORT || 3000;
|
|
|
|
function createServer() {
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const distPath = path.join(__dirname, "dist");
|
|
|
|
app.use(express.static(distPath));
|
|
|
|
app.get("*a", function (_, res) {
|
|
res.sendFile(path.join(distPath, "index.html"));
|
|
});
|
|
|
|
app.listen(port, function () {
|
|
console.log("server running on " + port);
|
|
});
|
|
}
|
|
|
|
createServer(); |