#Express (seemingly?) doesn't gzips what it sends back

7 messages · Page 1 of 1 (latest)

humble vector
#

The title is self-explanatory, here's the truncated code:

const compress = require("compression");
const api: Express = express();

function shouldCompress(req: Request, res: Response) {
    if (req.headers['x-no-compression']) return false;
    return compress.filter(req, res);
};

api.use(express.json());
api.use(compress({ threshold: 0, filter: shouldCompress }));
api.get(["*", "/status"], apiGet);
api.post("/update", apiPost);
api.listen(port, () => console.log(`⚡️[server]: API Server is running at http://localhost:${port}`));
#

With compression on:

#

With compression of:

#

the size stays 19.2kb

minor skiff
#

Please don't crosspost. We prefer people use this forum :)

humble vector