Files
COMP-2707-final-project/frontend/serve.js

34 lines
719 B
JavaScript

const express = require("express");
const path = require("path");
const app = express();
app.use("/*", (req, res, next) => {
now = new Date();
var datetime =
now.getFullYear() +
"/" +
(now.getMonth() + 1) +
"/" +
now.getDate() +
" " +
now.getHours() +
":" +
now.getMinutes() +
":" +
now.getSeconds();
console.log(datetime, req.method, req.baseUrl);
res.setHeader("X-Powered-By", "Ligma"); // Hide server to the client
next();
});
app.use(express.static(path.join(__dirname, "build")));
app.get("/*", function (_, res) {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
app.listen(8080, () => {
console.log("Server started on port 8080");
});