Skip to content

Commit

Permalink
improve static file serving
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed May 12, 2021
1 parent d120606 commit cd10a4f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ function checkRedis() {
checkRedis();

if (fs.existsSync("./dist")) {
app.use(express.static(__dirname + "/dist", false));
// serve static files without creating a bunch of sessions
app.use(express.static(__dirname + "/dist", {
maxAge: "2 days",
redirect: false,
index: false,
}));
}
else {
log.warn("no dist folder found");
Expand Down Expand Up @@ -203,12 +208,7 @@ function serveBuiltFiles(req, res) {
app.use("/api/user", usermanager.router);
app.use("/api", api);
if (fs.existsSync("./dist")) {
app.get("/", serveBuiltFiles);
app.get("/faq", serveBuiltFiles);
app.get("/rooms", serveBuiltFiles);
app.get("/room/:roomId", serveBuiltFiles);
app.get("/privacypolicy", serveBuiltFiles);
app.get("/quickroom", serveBuiltFiles);
app.get("*", serveBuiltFiles);
}
else {
log.warn("no dist folder found");
Expand Down

0 comments on commit cd10a4f

Please sign in to comment.