Skip to content

Commit

Permalink
send error with right content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Jul 21, 2024
1 parent 85625bf commit c9df94f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/middleware/node/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ export function createNodeHandler(
const errorMessage = err.message
? `${err.name}: ${err.message}`
: "Error: An Unspecified error occurred";
response.statusCode =

const statusCode =
typeof err.status !== "undefined" ? err.status : 500;

logger.error(error);

response.writeHead(statusCode, {
"content-type": "application/json"
});

response.end(
JSON.stringify({
error: errorMessage,
Expand Down

0 comments on commit c9df94f

Please sign in to comment.