From c905728c7065d70391cc4163978f0c017fe4c706 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 6 Sep 2023 19:00:42 +0700 Subject: [PATCH] fix: error handler --- controllers/errorsController.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/errorsController.js b/controllers/errorsController.js index 00e9ba6..260f306 100644 --- a/controllers/errorsController.js +++ b/controllers/errorsController.js @@ -13,8 +13,8 @@ const self = { self.handleError = (req, res, error) => { if (!res || res.headersSent) { - logger.error('Error: Unexpected missing "res" object or headers alredy sent.') - return logger.error(error) + logger.error(error) + return } res.header('Cache-Control', 'no-store') @@ -62,6 +62,8 @@ self.handleError = (req, res, error) => { } self.handleNotFound = (req, res) => { + if (!res || res.headersSent) return + res.header('Cache-Control', 'no-store') return res .status(404)