Prevent headers already sent error
This commit is contained in:
parent
e6de476ae8
commit
8fe17abb7c
|
@ -1,12 +1,11 @@
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
|
|
||||||
async function activityPubResponse (promise: Promise<any>, res: express.Response) {
|
export async function activityPubResponse (promise: Promise<any>, res: express.Response) {
|
||||||
const data = await promise
|
const data = await promise
|
||||||
|
|
||||||
return res.type('application/activity+json; charset=utf-8')
|
if (!res.headersSent) {
|
||||||
.json(data)
|
res.type('application/activity+json; charset=utf-8')
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
return res.json(data)
|
||||||
activityPubResponse
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue