'How to serve static brotli spa site?

I've made spa site and compressed it using brotli, but how to serve these files?

When I'm trying to code like

app.use(express.static(path.join(__dirname, "../", "prerendered")));

app.use(function (req, res) {
  res.sendFile(path.join(__dirname, "../", "prerendered", "index.html.br"));
  res.set("Content-Encoding", "brotli");
});

it's not working... What I'm doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source