Fixed error when serving public images from servePublicFile middleware

no issue

- when `servePublicFile` middleware serves an image it resulted in a "Cannot set headers after they are sent to the client" error because `next()` was erroneously called for successful requests which then tripped the `prettyUrls` middleware which tries to perform a redirect
- only calling `next()` when an error is present allows errors to be picked up by later middleware but successful requests end in the `servePublicFile` middleware
This commit is contained in:
Kevin Ansfield 2020-02-16 23:24:01 +00:00
parent 8def4fb402
commit 02c034068c

View File

@ -30,7 +30,9 @@ function createPublicFileMiddleware(file, type, maxAge) {
}));
}
return next(err);
if (err) {
return next(err);
}
});
}