diff --git a/packages/cli/src/WebhookHelpers.ts b/packages/cli/src/WebhookHelpers.ts index 2eb083e36bc24..0ef649d0ab16e 100644 --- a/packages/cli/src/WebhookHelpers.ts +++ b/packages/cli/src/WebhookHelpers.ts @@ -113,7 +113,13 @@ export const webhookRequestHandler = // Don't respond, if already responded if (response.noWebhookResponse !== true) { - ResponseHelper.sendSuccessResponse(res, response.data, true, response.responseCode); + ResponseHelper.sendSuccessResponse( + res, + response.data, + true, + response.responseCode, + response.headers, + ); } }; diff --git a/packages/cli/test/unit/webhooks.test.ts b/packages/cli/test/unit/webhooks.test.ts index 804d3d8d3602a..f4b1b02d5b8f8 100644 --- a/packages/cli/test/unit/webhooks.test.ts +++ b/packages/cli/test/unit/webhooks.test.ts @@ -56,20 +56,24 @@ describe('WebhookServer', () => { it('should handle regular requests', async () => { const pathPrefix = config.getEnv(`endpoints.${key}`); manager.getWebhookMethods.mockResolvedValueOnce(['GET']); - manager.executeWebhook.mockResolvedValueOnce(mockResponse({ test: true })); + manager.executeWebhook.mockResolvedValueOnce( + mockResponse({ test: true }, { key: 'value ' }), + ); const response = await agent.get(`/${pathPrefix}/abcd`).set('origin', corsOrigin); expect(response.statusCode).toEqual(200); expect(response.body).toEqual({ test: true }); expect(response.headers['access-control-allow-origin']).toEqual(corsOrigin); + expect(response.headers.key).toEqual('value'); }); }); } - const mockResponse = (data = {}, status = 200) => { + const mockResponse = (data = {}, headers = {}, status = 200) => { const response = mock(); response.responseCode = status; response.data = data; + response.headers = headers; return response; }; });