backend-common: use explicit content type in error response

This commit is contained in:
Patrik Oldsberg
2021-02-08 12:21:47 +01:00
parent 0b08c09dce
commit 82af0855bc
@@ -63,10 +63,10 @@ export function errorHandler(
return (
error: Error,
_request: Request,
response: Response,
res: Response,
next: NextFunction,
) => {
if (response.headersSent) {
if (res.headersSent) {
// If the headers have already been sent, do not send the response again
// as this will throw an error in the backend.
next(error);
@@ -80,7 +80,9 @@ export function errorHandler(
logger.error(error);
}
response.status(status).send(message);
res.status(status);
res.setHeader('content-type', 'text/plain');
res.send(message);
};
}