37 lines
795 B
JavaScript
37 lines
795 B
JavaScript
const express = require("express");
|
|
const path = require("path");
|
|
const app = express();
|
|
const dotenv = require('dotenv');
|
|
dotenv.config()
|
|
console.log(process.env);
|
|
|
|
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");
|
|
});
|