Explorar o código

ajax,开启gzip压缩

MaiXinRong %!s(int64=5) %!d(string=hai) anos
pai
achega
f72f0e6abc
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      app/middleware/gzip.js

+ 2 - 2
app/middleware/gzip.js

@@ -18,12 +18,12 @@ module.exports = options => {
         // 后续中间件执行完成后将响应体转换成 gzip
         let body = ctx.body;
         if (!body) return;
-        if (isJSON(body)) return;
+        //if (isJSON(body)) return;
 
         // 支持 options.threshold
         if (options.threshold && ctx.length < options.threshold) return;
 
-        //if (isJSON(body)) body = JSON.stringify(body);
+        if (isJSON(body)) body = JSON.stringify(body);
 
         // 设置 gzip body,修正响应头
         const stream = zlib.createGzip();