Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Oct 25, 2023
1 parent 1d8764c commit fd2e926
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fd2e926

Please sign in to comment.