Skip to content

Commit

Permalink
fix: set header when response sent in ApiErrorHandler
Browse files Browse the repository at this point in the history
- Use chain fn instead of `writeHead` to prevent `.json` set header two times
  • Loading branch information
Chinlinlee committed Jan 3, 2024
1 parent f547447 commit 432ce6b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions error/api-errors.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 432ce6b

Please sign in to comment.