Revamp vanilla-app

This commit is contained in:
Jerome Wu
2023-08-05 14:41:45 +08:00
parent 2a757fc760
commit 4d559bd267
12 changed files with 133 additions and 61 deletions

View File

@@ -0,0 +1,19 @@
const path = require("path");
const express = require("express");
const serveIndex = require("serve-index");
const app = express();
const PORT = 8080;
const ROOT = path.join(__dirname, "public");
app.use((_, res, next) => {
res.append("Cross-Origin-Opener-Policy", "same-origin");
res.append("Cross-Origin-Embedder-Policy", "require-corp");
next();
});
app.use(express.static(ROOT));
app.use("/", serveIndex(ROOT));
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
});