title: Express.js and intercepting .js requests and serving .gz instead
body: <p>So, I am using webpack to compress/gzip my js files. Then I want to use my Express server to serve those up when a .js request comes in. I am having a devil of a time getting this to work in production. I am able to in dev. I feel it has to do with how I am setting my static files. Assitance?</p>
  
  <pre><code>app.use(express.static(path.join(__dirname, 'build')));
  app.get('*', (req, res) =&gt; {
      res.sendFile(path.join(__dirname, 'build', 'index.html'));
  });
  
  // THIS is not working
  app.get("*.js", function (req, res, next) {
      req.url = req.url + '.gz';
      res.set('Content-Encoding', 'gzip');
      next();
  });
  </code></pre>
  
  <p>I tried positioning above, middle etc.. of the above code. Not working. I know my webpack is building it as I see the output in the build folder. I just can't seem to get my express server to serve up the .gz version.</p>