From 432ce6ba378760c18949e4191f6cbd2a1c18fe59 Mon Sep 17 00:00:00 2001 From: chinlinlee Date: Wed, 3 Jan 2024 15:36:40 +0800 Subject: [PATCH] fix: set header when response sent in ApiErrorHandler - Use chain fn instead of `writeHead` to prevent `.json` set header two times --- error/api-errors.handler.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/error/api-errors.handler.js b/error/api-errors.handler.js index bcb2c0b6..9ca10fda 100644 --- a/error/api-errors.handler.js +++ b/error/api-errors.handler.js @@ -90,10 +90,7 @@ class ApiErrorArrayHandler { apiLogger.logger.error(e); if (!response.headersSent) { - response.writeHead(500, { - "Content-Type": "application/dicom+json" - }); - return response.json(getInternalServerErrorMessage("An exception occurred")); + return response.status(500).set("content-type", "application/dicom+json").send(getInternalServerErrorMessage("An exception occurred")); } return response.end(); }