Skip to content

Commit

Permalink
fix(core): Setup webhook stopping endpoint after the CORS middleware …
Browse files Browse the repository at this point in the history
…(no-changelog) (#9454)
  • Loading branch information
netroy authored May 17, 2024
1 parent 04dd476 commit 6f2d83b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/cli/src/AbstractServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit 6f2d83b

Please sign in to comment.