Sending compressed html content through brotli not working
The-Lord-of-Owls opened this issue · comments
I have tried with Content-Type: br and Content-Type: text/html, aswell as both with and without the Accept-Encoding: br header.
Ever attempt has resulted in the browser only displaying the compressed html as a string without decompressing it at all. Happens in both latest version of chrome and firefox.
const pageFormat = brotli.compress( fs.readFileSync( './html/index.html', { encoding: 'utf8' } ) )
app.get( '/', ( req, res ) => {
res.setHeader( 'Content-Type', 'text/html' )
res.setHeader( 'Accept-Encoding', 'br' )
res.end( pageFormat )
} )
You should use Content-Encoding
instead of Accept-Encoding
in the response.