Reputation: 7500
Using Octokit 3.1.2, this does not work:
import { createServer } from "node:http"
import { App, createNodeMiddleware } from "octokit"
const app = new App({
...
})
createServer(createNodeMiddleware(app.webhooks, { path: "/myapi/github/webhooks" })).listen(3001)
The middleware rejects all requests.
Upvotes: 0
Views: 92
Reputation: 7500
This is because the options for Middleware have changed, as per this documentation on octokit/app.js. The above code must be changed to the following to work:
createServer(createNodeMiddleware(app, { pathPrefix: "/myapi/github" })).listen(3001)
Note that both the behavior (path is now a path prefix) and the default value (/api/github/webhooks
-> /api/github
) have changed!
This burned over five hours of my time! I filed a bug here. https://github.com/octokit/webhooks.js/issues/946
Upvotes: 0