After session destroyed and goes -1 in historie session is still “active” | NodeJS & Express

94
January 10, 2020, at 8:00 PM

I have a login system and when the I log out (session is destroyed). Then when I go back to the page where I logged out from it still loads, but first when reload the page then it sees that the session is destroyed.

What can I do so I/user can't go back and see the page?

Automation function for each of my pages:

const pkAuth = (req, res, user, callback) => {
    if (!user) {
        res.writeHead(302, {
            'location': '/giveRedirectPK?Link=?Err=notLoggedIn'
        });
        res.end();
    } else {
        var token = user['privateToken'];
        var legit = jwt.verify(token, publicKEY, function (err, decoded) {
            if (err) {
                if (err.name === 'TokenExpiredError' && decoded === undefined) {
                    var wasOnLink = req.protocol + '://' + req.get('host') + req.originalUrl;
                    req.session.tokenExpired = {
                        type: true,
                        link: wasOnLink
                    };
                    res.writeHead(302, {
                        'location': '/giveRedirectPK?Link=?Err=notLoggedIn'
                    });
                    res.end();
                }
            } else {
                callback(true);
            }
        });
    }
};

My signout POST:

server.post('/pk/pkSignout', (req, res) => {
    req.session.destroy(err => {
        res.writeHead(302, {
            'location': '/giveRedirectPK?Link=',
        });
        res.end();
    });
});
READ ALSO
Node Electron synch text append

Node Electron synch text append

I am trying to make an Electron app that will read given directory recursively and print file names to userLuckily I found a function on GitHub which makes exactly what I want

79
Data and salt arguments required error (authorization)

Data and salt arguments required error (authorization)

I'm a beginner in NodeJS and I've tried to make an authentication form using NodeJS + expressI want to make a validation for my password (when "confirmpassword" is different than "password" it should return nothing

205
Configuring express gateway to work with redis

Configuring express gateway to work with redis

I'm setting up an instance of the express gateway for routing requests to microservicesIt works as expected, but I get the following errors when I try to include redis in my system config

93
Heroku fetching api data : Error 414 URI too long

Heroku fetching api data : Error 414 URI too long

I have a nodejs server deployed on heorku (hosting provider) and i'm receiving a 414 URI Too Long error

77