Prevent exception when headers are already sent

pull/5762/head
Chocobozzz 2023-04-14 09:34:53 +02:00
parent 3f9f1bceb6
commit 848347f193
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 4 additions and 1 deletions

View File

@ -18,7 +18,10 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e
})
res.status(status)
if (!res.headersSent) {
res.setHeader('Content-Type', 'application/problem+json')
}
const json = new ProblemDocument({
status,