Answer the question
In order to leave comments, you need to log in
How to serve a static brotli site?
Hello, I have a spa site compressed to brotli,
how can I serve it.
For example
app.use(express.static(path.join(__dirname, "../", "prerendered")));
app.use(function (req, res) {
res.sendFile(path.join(__dirname, "../", "prerendered", "index.html"));
});
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");
});
Answer the question
In order to leave comments, you need to log in
Try this
app.use(function (req, res) {
res.writeHead(200, {
'Content-Encoding': 'brotli';
})
res.sendFile(path.join(__dirname, "../", "prerendered", "index.html.br"));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question