Using the Express framework for node.js, I\'m trying to serve up static files contained in a directory while also putting basic authentication on it. When I do so, I am prompted
Im sharing how it worked out for me.
app.use("/login", (req, res, next) => {
if (req.cookies.UUID) {
res.redirect("/app");
} else {
next();
}
});
app.use("/login", express.static("dist_auth_app"));
app.use("/app", (req, res, next) => {
if (!req.cookies.UUID) {
res.redirect("/login");
} else {
next();
}
});
app.use("/app", express.static("dist"));