Prevent exception when headers are already sent
This commit is contained in:
parent
3f9f1bceb6
commit
848347f193
1 changed files with 4 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue