From 175a01b6086e7762ab75daa1f1fa631dec00c1b6 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Thu, 15 Dec 2022 14:24:27 +0100 Subject: [PATCH] Disable compression for development proxy (#6699) * disable compression in dev proxy when proxying JS files to speed up local development * clean up --- tools/proxy/proxy.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/proxy/proxy.js b/tools/proxy/proxy.js index b1db656077f..38bd093f909 100644 --- a/tools/proxy/proxy.js +++ b/tools/proxy/proxy.js @@ -105,6 +105,14 @@ function toWebpackDev(req, res) { proxy.web(req, res, { target: `http://127.0.0.1:${PORT + 2}` }); } +proxy.on("proxyReq", (proxyReq, req) => { + if (req.url.match(/\/assets\/bundle\/.+\.js/)) { + // Disable compression for JS files, as the performance penalty of the compression + // isn't worth the size gain. + proxyReq.removeHeader("Accept-Encoding"); + } +}); + app.all("/assets/bundle/*", toWebpackDev); app.all("/*", toBackend);