You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to modify the response body after I use the serve-static middleware , but I am very confused why serve-static only call next() when error happens, I saw other middleware's code ,like compression,cookie-session ,finally they all call next() method.
The text was updated successfully, but these errors were encountered:
Hi @kimown, the reason this module does not call next() unless it's an error is because in Express and the middleware pattern, you only call next() if you either (a) encountered an error or (b) did not write out a response body.
Since this module writes out a response body, it does not call next(), as this module already handled the request by sending a response. All the other examples you gave (compression and cookie-session) are not sending a response back, thus they are calling next() in the non-error case.
I want to modify the response body after I use the serve-static middleware , but I am very confused why serve-static only call
next()
when error happens, I saw other middleware's code ,like compression,cookie-session ,finally they all call next() method.The text was updated successfully, but these errors were encountered: