feat(webhooks/respond-with): accept custom headers

This commit is contained in:
Ali BARIN
2024-03-19 19:21:20 +00:00
parent 9a63b213b0
commit 473d287c6d
3 changed files with 52 additions and 12 deletions

View File

@@ -75,9 +75,20 @@ export default async (flowId, request, response) => {
});
if (actionStep.key === 'respondWith' && !response.headersSent) {
const { headers, statusCode, body } = actionExecutionStep.dataOut;
// we set the custom response headers
if (headers) {
for (const [key, value] of Object.entries(headers)) {
if (key) {
response.set(key, value);
}
}
}
// we send the response only if it's not sent yet. This allows us to early respond from the flow.
response.status(actionExecutionStep.dataOut.statusCode);
response.send(actionExecutionStep.dataOut.body);
response.status(statusCode);
response.send(body);
}
}
}