diff --git a/src/middleware/node/handler.ts b/src/middleware/node/handler.ts index 79d7d852..7fd5caf8 100644 --- a/src/middleware/node/handler.ts +++ b/src/middleware/node/handler.ts @@ -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,