From 8fe17abb7c6b14d4613ad5173f64d7d30f01068f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 14 Aug 2024 14:21:53 +0200 Subject: [PATCH] Prevent headers already sent error --- server/core/controllers/activitypub/utils.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/core/controllers/activitypub/utils.ts b/server/core/controllers/activitypub/utils.ts index 5de38eb43..3954a1105 100644 --- a/server/core/controllers/activitypub/utils.ts +++ b/server/core/controllers/activitypub/utils.ts @@ -1,12 +1,11 @@ import express from 'express' -async function activityPubResponse (promise: Promise, res: express.Response) { +export async function activityPubResponse (promise: Promise, res: express.Response) { const data = await promise - return res.type('application/activity+json; charset=utf-8') - .json(data) -} + if (!res.headersSent) { + res.type('application/activity+json; charset=utf-8') + } -export { - activityPubResponse + return res.json(data) }