add previous url
This commit is contained in:
parent
843700e27c
commit
60d4a477bd
|
@ -0,0 +1,19 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const glob = require('glob');
|
||||
|
||||
glob(__dirname + "/**/*.js", {}, (er, data) => {
|
||||
if (er) {
|
||||
console.error(er);
|
||||
process.exit(-1);
|
||||
}
|
||||
data
|
||||
.filter(file => {
|
||||
return !file.endsWith('index.js')
|
||||
})
|
||||
.forEach(file => {
|
||||
require(file)(router);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
|
@ -0,0 +1,16 @@
|
|||
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);
|
||||
}
|
Loading…
Reference in New Issue