mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-31 23:52:48 +00:00
Identify API errors and send error response
This commit is contained in:
@@ -489,6 +489,12 @@ app.use(async (err, req, res, next)=>{
|
|||||||
};
|
};
|
||||||
req.customUrl= '/error';
|
req.customUrl= '/error';
|
||||||
|
|
||||||
|
if(req.originalUrl.startsWith('/api/')) {
|
||||||
|
console.log('api error');
|
||||||
|
res.status(err?.status || err?.response?.status || 500).send(err.message || err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const page = await renderPage(req, res);
|
const page = await renderPage(req, res);
|
||||||
if(!page) return;
|
if(!page) return;
|
||||||
res.send(page);
|
res.send(page);
|
||||||
|
|||||||
Reference in New Issue
Block a user