homepage.js/middleware/session_back.js

19 lines
436 B
JavaScript
Raw Normal View History

2023-02-25 07:39:30 +01:00
const express = require('express');
const router = express.Router();
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();
}
2023-02-25 07:39:30 +01:00
router.use(handler);
module.exports = router