diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts index 7b116eb57..540edaeeb 100644 --- a/server/middlewares/error.ts +++ b/server/middlewares/error.ts @@ -18,7 +18,10 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e }) res.status(status) - res.setHeader('Content-Type', 'application/problem+json') + + if (!res.headersSent) { + res.setHeader('Content-Type', 'application/problem+json') + } const json = new ProblemDocument({ status,