Add more control
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user