diff --git a/modules/caddyhttp/routes.go b/modules/caddyhttp/routes.go index 83e63540..ebd763c7 100644 --- a/modules/caddyhttp/routes.go +++ b/modules/caddyhttp/routes.go @@ -220,7 +220,11 @@ func wrapRoute(route Route) Middleware { // make terminal routes terminate if route.Terminal { - nextCopy = emptyHandler + if _, ok := req.Context().Value(ErrorCtxKey).(error); ok { + nextCopy = errorEmptyHandler + } else { + nextCopy = emptyHandler + } } // compile this route's handler stack