File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,14 @@ export class ExpressDriver extends BaseDriver {
150150 // prepare route and route handler function
151151 const route = ActionMetadata . appendBaseRoute ( this . routePrefix , actionMetadata . fullRoute ) ;
152152 const routeHandler = function routeHandler ( request : any , response : any , next : Function ) {
153+ // Express calls the "get" route automatically when we call the "head" route:
154+ // Reference: https://expressjs.com/en/4x/api.html#router.METHOD
155+ // This causes a double action execution on our side, which results in an unhandled rejection,
156+ // saying: "Can't set headers after they are sent".
157+ // The following line skips action processing when the request method does not match the action method.
158+ if ( request . method . toLowerCase ( ) !== actionMetadata . type )
159+ return next ( ) ;
160+
153161 return executeCallback ( { request, response, next} ) ;
154162 } ;
155163
You can’t perform that action at this time.
0 commit comments