From 5e5c637c79b252e4d5a1003bb0a9ce8235e4e76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Sat, 14 Dec 2024 20:59:51 +0100 Subject: [PATCH] revert api catch on wrong route middleware --- server/app.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/server/app.js b/server/app.js index 4c6c9ba1f..b10f36c4e 100644 --- a/server/app.js +++ b/server/app.js @@ -346,7 +346,7 @@ app.get('/user/:username', async (req, res, next)=>{ return next(); }); -//Rename Brews +//Change author name on brews app.put('/api/user/rename', async (req, res) => { const { username, newUsername } = req.body; @@ -538,14 +538,11 @@ app.get('/vault', asyncHandler(async(req, res, next)=>{ //Send rendered page app.use(asyncHandler(async (req, res, next) => { - if (!req.route && !req.path.startsWith('/api/')) { - return res.redirect('/'); - } + if (!req.route) return res.redirect('/'); // Catch-all for invalid routes - const page = await renderPage(req, res); - if (!page) return; - - res.send(page); + const page = await renderPage(req, res); + if(!page) return; + res.send(page); })); //Render the page