diff options
author | Chocobozzz <me@florianbigard.com> | 2023-04-14 09:34:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-04-14 09:34:53 +0200 |
commit | 848347f193ca43f098e77b321f6555bd4a143e62 (patch) | |
tree | 6cc70c9214f8fb26d233460785547318c3235a16 /server/middlewares/error.ts | |
parent | 3f9f1bceb6195652bfa5a8553461d630f2bf293b (diff) | |
download | PeerTube-848347f193ca43f098e77b321f6555bd4a143e62.tar.gz PeerTube-848347f193ca43f098e77b321f6555bd4a143e62.tar.zst PeerTube-848347f193ca43f098e77b321f6555bd4a143e62.zip |
Prevent exception when headers are already sent
Diffstat (limited to 'server/middlewares/error.ts')
-rw-r--r-- | server/middlewares/error.ts | 5 |
1 files changed, 4 insertions, 1 deletions
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 | |||
18 | }) | 18 | }) |
19 | 19 | ||
20 | res.status(status) | 20 | res.status(status) |
21 | res.setHeader('Content-Type', 'application/problem+json') | 21 | |
22 | if (!res.headersSent) { | ||
23 | res.setHeader('Content-Type', 'application/problem+json') | ||
24 | } | ||
22 | 25 | ||
23 | const json = new ProblemDocument({ | 26 | const json = new ProblemDocument({ |
24 | status, | 27 | status, |