From 02c034068cda9525633e00ba628e897c3b3056b5 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Sun, 16 Feb 2020 23:24:01 +0000 Subject: [PATCH] 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 --- core/server/web/shared/middlewares/serve-public-file.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/server/web/shared/middlewares/serve-public-file.js b/core/server/web/shared/middlewares/serve-public-file.js index 7f6b356316..4efbdf7811 100644 --- a/core/server/web/shared/middlewares/serve-public-file.js +++ b/core/server/web/shared/middlewares/serve-public-file.js @@ -30,7 +30,9 @@ function createPublicFileMiddleware(file, type, maxAge) { })); } - return next(err); + if (err) { + return next(err); + } }); }