homepage.js/middleware/session_back.js

16 lines
378 B
JavaScript
Raw Normal View History

2023-02-19 03:32:25 +01:00
async function handler(req, res, next) {
// TODO:
// Log only non-automatical requests
// In other words, ignore requests like favicon.ico
if (!req.accepts('html') && !req.accepts('*')) {
next();
return;
}
req.session.prev = req.originalUrl;
req.session.save();
next();
}
module.exports = (router) => {
router.use(handler);
}