From 7f8204bc0cbb0f9f32727897005a9a7067496761 Mon Sep 17 00:00:00 2001 From: wukko Date: Fri, 30 Aug 2024 14:25:46 +0600 Subject: [PATCH] api/core: handle all express errors, not just path parsing (wtf) --- api/src/core/api.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/api/src/core/api.js b/api/src/core/api.js index f8e7724b..9632d588 100644 --- a/api/src/core/api.js +++ b/api/src/core/api.js @@ -140,15 +140,6 @@ export const runAPI = (express, app, __dirname) => { app.post('/', apiLimiter); app.use('/stream', apiLimiterStream); - app.use((req, res, next) => { - try { - decodeURIComponent(req.path) - } catch { - return res.redirect('/') - } - next(); - }) - app.use('/', express.json({ limit: 1024 })); app.use('/', (err, _, res, next) => { if (err) { @@ -290,6 +281,11 @@ export const runAPI = (express, app, __dirname) => { res.redirect('/'); }) + // handle all express errors + app.use((err, req, res, next) => { + return fail(res, "error.api.generic"); + }) + randomizeCiphers(); setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes