From 6f2d83bffdc43e890c82177e4ceb35a9ffa7e90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 17 May 2024 17:55:29 +0200 Subject: [PATCH] fix(core): Setup webhook stopping endpoint after the CORS middleware (no-changelog) (#9454) --- packages/cli/src/AbstractServer.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/AbstractServer.ts b/packages/cli/src/AbstractServer.ts index 1610600e50..b458981c15 100644 --- a/packages/cli/src/AbstractServer.ts +++ b/packages/cli/src/AbstractServer.ts @@ -207,13 +207,6 @@ export abstract class AbstractServer { // Register a handler this.app.all(`/${this.endpointFormTest}/:path(*)`, webhookRequestHandler(testWebhooks)); this.app.all(`/${this.endpointWebhookTest}/:path(*)`, webhookRequestHandler(testWebhooks)); - - // Removes a test webhook - // TODO UM: check if this needs validation with user management. - this.app.delete( - `/${this.restEndpoint}/test-webhook/:id`, - send(async (req) => await testWebhooks.cancelWebhook(req.params.id)), - ); } // Block bots from scanning the application @@ -230,6 +223,16 @@ export abstract class AbstractServer { this.setupDevMiddlewares(); } + if (this.testWebhooksEnabled) { + const testWebhooks = Container.get(TestWebhooks); + // Removes a test webhook + // TODO UM: check if this needs validation with user management. + this.app.delete( + `/${this.restEndpoint}/test-webhook/:id`, + send(async (req) => await testWebhooks.cancelWebhook(req.params.id)), + ); + } + // Setup body parsing middleware after the webhook handlers are setup this.app.use(bodyParser);