From fd2e9268864df77160200b451e7a08d292f64b3c Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 24 Oct 2023 19:17:11 -0700 Subject: [PATCH] refactor code --- packages/next/src/server/next-server.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/next/src/server/next-server.ts b/packages/next/src/server/next-server.ts index 3b7861013cd63..c3c7855aff5c3 100644 --- a/packages/next/src/server/next-server.ts +++ b/packages/next/src/server/next-server.ts @@ -1585,19 +1585,16 @@ export default class NextNodeServer extends BaseServer { ) => { const isMiddlewareInvoke = req.headers['x-middleware-invoke'] - const handleFinished = (finished: boolean = false) => { - if (isMiddlewareInvoke && !finished) { - res.setHeader('x-middleware-invoke', '1') - res.body('').send() - return true - } - return finished - } - if (!isMiddlewareInvoke) { return false } + const handleFinished = () => { + res.setHeader('x-middleware-invoke', '1') + res.body('').send() + return true + } + const middleware = this.getMiddleware() if (!middleware) { return handleFinished()