mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
added extra logging for debugging CSRF issues
This commit is contained in:
12
src/app.js
12
src/app.js
@@ -67,6 +67,18 @@ require('./routes/routes').register(app);
|
||||
|
||||
require('./routes/custom').register(app);
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
if (err.code !== 'EBADCSRFTOKEN') {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
log.error(`Invalid CSRF token: ${req.headers['x-csrf-token']}, secret: ${req.cookies['_csrf']}`);
|
||||
|
||||
err = new Error('Invalid CSRF token');
|
||||
err.status = 403;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use((req, res, next) => {
|
||||
const err = new Error('Router not found for request ' + req.url);
|
||||
|
||||
Reference in New Issue
Block a user