Skip to content

Commit

Permalink
fix: server.preCompressed might not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh committed Oct 5, 2019
1 parent a9c98bd commit c932a08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/middlewares/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function(app) {
const { config, route } = this;
const { args = {} } = this.env;
const { root, server } = config;
const preCompressed = server.preCompressed ? server.preCompressed.enable : false;

if (args.s || args.static) return;

Expand All @@ -29,7 +30,7 @@ module.exports = function(app) {
return;
}

if (!server.preCompressed.enable || (!req.url.endsWith('gz') && !req.url.endsWith('br'))) {
if (!preCompressed || (!req.url.endsWith('gz') && !req.url.endsWith('br'))) {
res.setHeader('Content-Type', extname ? mime.getType(extname) : 'application/octet-stream');
}

Expand Down

0 comments on commit c932a08

Please sign in to comment.