Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending compressed html content through brotli not working #44

Open
The-Lord-of-Owls opened this issue Feb 24, 2023 · 1 comment
Open

Comments

@The-Lord-of-Owls
Copy link

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 )
} )
@nand2
Copy link

nand2 commented Feb 9, 2024

You should use Content-Encoding instead of Accept-Encoding in the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants