I am using connect-flash to have a flash message in my sailjs app. The flash message persists even after refreshing the page. I tried the solution on this
I created a policy to clear the req.session.flash
array before any request but doing that shows no flash message any time. What's the correct way to show the flash message only once?
Edit :-
Code in my policy :-
//removeFlash.js
module.exports = async function(req, res, next) {
req.session.flash = {};
next();
};
policies.js contains
'*' : 'removeFlash'
My controller contains
req.flash("error_msg", "Incorrect username or password.");
return res.redirect("/login");