mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api/core: handle all express errors, not just path parsing (wtf)
This commit is contained in:
parent
329b068038
commit
7f8204bc0c
1 changed files with 5 additions and 9 deletions
|
@ -140,15 +140,6 @@ export const runAPI = (express, app, __dirname) => {
|
||||||
app.post('/', apiLimiter);
|
app.post('/', apiLimiter);
|
||||||
app.use('/stream', apiLimiterStream);
|
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('/', express.json({ limit: 1024 }));
|
||||||
app.use('/', (err, _, res, next) => {
|
app.use('/', (err, _, res, next) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -290,6 +281,11 @@ export const runAPI = (express, app, __dirname) => {
|
||||||
res.redirect('/');
|
res.redirect('/');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// handle all express errors
|
||||||
|
app.use((err, req, res, next) => {
|
||||||
|
return fail(res, "error.api.generic");
|
||||||
|
})
|
||||||
|
|
||||||
randomizeCiphers();
|
randomizeCiphers();
|
||||||
setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes
|
setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue