diff --git a/server/app.js b/server/app.js index a19030b3a..5ae873a1c 100644 --- a/server/app.js +++ b/server/app.js @@ -472,9 +472,18 @@ const getPureError = (error)=>{ }; app.use(async (err, req, res, next)=>{ - const status = err.status || err.code || 500; + err.originalUrl = req.originalUrl; console.error(err); + if(err.originalUrl?.startsWith('/api/')) { + // console.log('API error'); + res.status(err.status || err.response?.status || 500).send(err.message || err); + return; + } + + // console.log('non-API error'); + const status = err.status || err.code || 500; + req.ogMeta = { ...defaultMetaTags, title : 'Error Page', description : 'Something went wrong!'