Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes 404 when request header Accept-Encoding not set

When static middleware is enabled, sending a request without
Accept-Encoding set would cause a premature call to pass()
before checking if the requested file exists. This meant that
calls to normal Express routes would be intercepted and result
in 404s.
  • Loading branch information...
commit 10d18173f67d0bf8047584bceba98b592afbf2ee 1 parent bca6fd4
@underbluewaters authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/staticGzip.js
View
4 lib/staticGzip.js
@@ -209,7 +209,6 @@ exports = module.exports = function staticGzip(dirPath, options){
}
}
- if (!method) return pass(filename);
fs.stat(filename, function(err, stat) {
@@ -221,6 +220,9 @@ exports = module.exports = function staticGzip(dirPath, options){
return next();
}
+ // Check if file exists before passing uncompressed to client
+ if (!method) return pass(filename);
+
if (!contentTypeMatch.test(contentType)) {
return pass(filename);
}
Please sign in to comment.
Something went wrong with that request. Please try again.