I want to achieve the following:
/login <- login page (static dir); after success it navigates to /app
/app <-redirects to either /app/board or to /app/calendar according to some req.session.param
/app/board <- app1 (static dir)
/app/calendar <- app2 (static dir)
The problem is when I do this:
webServer.use("/login", (req, res, next) => {
if (req.session.isLogged) {
res.redirect("/app");
} else {
next();
}
});
webServer.use("/login", express.static("dist/auth"));
webServer.use("/app/board", (req, res, next) => {
if (!req.session.isLogged) {
res.redirect("/login");
} else {
if (req.session.application === CALENDAR) {
res.redirect("/app/calendar");
} else {
next();
}
}
});
webServer.use("/app/board", express.static("dist/board"));
webServer.use("/app", (req, res, next) => {
if (!req.session.isLogged) {
res.redirect("/login");
} else {
if (req.session.application === CALENDAR) {
res.redirect("/app/calendar");
} else {
res.redirect("/app/board");
}
}
});
I get some content from the expected /app/board but nothing else much except Refused to execute script from 'https://localhost:1337/app/board/' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
I searched for answers, but none worked (including using __dirname);
Funny enough when I mount either app to /app instead of to the nested /app/something the problem goes away. This leads me to the thought that it is somehow nesting-related and has something to do with the middle-wares I specify.
I am new to express, what am I missing?