Reputation: 33
I have a query regarding back button. As we know that after pressing logout button, if user presses back button than it must be redirect to the login page not to the authenticated page. I tried to find the solution but can't fix it out in my case.
Thanks in Advance
Here is my routes.js screenshot:
Upvotes: 1
Views: 2644
Reputation: 99
You can use ensureLoggedIn
First install ensureLoggedIn by npm install
var ensureLoggedIn=require("connect-ensure-login").ensureLoggedIn
app.get('/profile', ensureLoggedIn('/login'),function(req,res){
res.sendFile(__dirname +'/public/selflocates.html');
})
Upvotes: 0
Reputation: 3194
When the user navigates back in the browser, the data is shown from the local browser cache, and not requested from your server.
Using the following setup when the browser back button, the page is reloaded and not cached.
// caching disabled for every route
server.use(function(req, res, next) {
res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
next();
});
// otherwise put the res.set() call into the route-handler you want
Upvotes: 4