Skip to content

Commit f7df85e

Browse files
authored
Pass on to the next middleware in case of express
As I explained [here](octokit#509 (comment)), it is now required to always install this middleware to the end of the chain, otherwise it rejects all requests it cannot handle.
1 parent 024e3ee commit f7df85e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/middleware/node/middleware.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ export async function middleware(
2323

2424
const isUnknownRoute = request.method !== "POST" || pathname !== options.path;
2525
const isExpressMiddleware = typeof next === "function";
26-
if (!isExpressMiddleware && isUnknownRoute) {
27-
return options.onUnhandledRequest(request, response);
26+
if (isUnknownRoute) {
27+
if (isExpressMiddleware) {
28+
return next();
29+
} else {
30+
return options.onUnhandledRequest(request, response);
31+
}
2832
}
2933

3034
const missingHeaders = getMissingHeaders(request).join(", ");

0 commit comments

Comments
 (0)