Skip to content

Commit bc32b22

Browse files
committed
fix: adds gzip
1 parent c2e5e34 commit bc32b22

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/index.server.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import proxy from 'koa-better-http-proxy';
55
import Router from '@koa/router';
66
import ssrMiddleware from './server/ssrMiddleware';
77
import rateLimitMiddleware from './server/rateLimitMiddleware';
8+
import compress from 'koa-compress';
9+
import { constants } from 'zlib';
810

911
console.log(process.env.REACT_APP_SSR);
1012

@@ -13,6 +15,22 @@ const router = new Router();
1315

1416
app.proxy = true;
1517

18+
app.use(
19+
compress({
20+
filter(contentType) {
21+
return /text/i.test(contentType);
22+
},
23+
threshold: 2048,
24+
gzip: {
25+
flush: constants.Z_SYNC_FLUSH,
26+
},
27+
deflate: {
28+
flush: constants.Z_SYNC_FLUSH,
29+
},
30+
br: false, // disable brotli
31+
}),
32+
);
33+
1634
app.use(
1735
serve(path.resolve('./build'), {
1836
index: false,

0 commit comments

Comments
 (0)