The session validation should be checked before every page is loaded and the login page should be redirected

OK I think I can see what is going on.

try this...

Your Middleware

function sessionValidation(req, res, next) {
    const sessionId = req.cookies['session_id'];
    if (sessionId) {
        next()
    } else {
        res.redirect('/api/login');
    }
}

Settings.JS

    /** The following property can be used to add a custom middleware function
     * in front of all http in nodes. This allows custom authentication to be
     * applied to all http in nodes, or any other sort of common request processing.
     * It can be a single function or an array of middleware functions.
     */
    httpNodeMiddleware: sessionValidation,

    /** When httpAdminRoot is used to move the UI to a different root path, the
     * following property can be used to identify a directory of static content
     * that should be served at http://localhost:1880/.
     * When httpStaticRoot is set differently to httpAdminRoot, there is no need
     * to move httpAdminRoot
     */

Just tested this - and it works

1 Like