1
0
Fork 0

Prevent exception when headers are already sent

This commit is contained in:
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

View file

@ -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,