stavroskasidis / BlazorWasmAntivirusProtection

Antivirus protection for Blazor Wasm projects
MIT License
69 stars 13 forks source link

Brotli Compression Issue #42

Closed Xeio closed 1 year ago

Xeio commented 1 year ago

I think there may be an issue with the Brotli compression on version 2.2.1 (I haven't tried most of the versions between 1.8.5 and 2.2.1). I didn't notice till recently since I'm deployed behind Cloudflare and they seem to request the uncompressed asset generally.

This was specifically trying to access the /_framework/blazor.boot.json file, though I didn't really try with others since that's the first one to fail in the load process.

If I try and use Postman with "Accept-Encoding": "gzip, deflate, br" the request returns a 200 OK but a zero-length file. Works fine if I request after removing "br" in which case I get back a gzip encoding, and also works fine with no Accept-Encoding in which case I get back a non-compressed file.

Not entirely sure why this blows up like it does, I'm guessing Kestrel isn't liking the file for some reason? This is on .Net 7 (running on a Linux docker container from the standard MS containers) for reference as well. No errors logged anywhere that I can tell in either my host container on the Nginx proxy in front of it.

stavroskasidis commented 1 year ago

There was a brotli compression bug in 2.2.0 when publishing from a non-windows device. It should work in 2.2.1, did you properly update both projects? (server/client).

When you publish the project locally, does the blazor.boot.json.br file have contents or is it zero-length file?

Xeio commented 1 year ago

Ah, so that's interesting, I published to folder everything seemingly works correctly, I get a non-zero length file (Visual Studio 2022 publish to folder on Windows).

But inside my docker container (published using VS on the same system) it looks like this:

root@b7a56d3250df:/app/wwwroot/_framework# ls -hl blazor.boot*
-rw-r--r-- 1 root root 9.5K Nov 20 20:55 blazor.boot.json
-rw-r--r-- 1 root root    0 Nov 20 20:55 blazor.boot.json.br
-rw-r--r-- 1 root root 4.4K Nov 20 20:55 blazor.boot.json.gz

I'm pretty much just using the default docker file for Asp Core, the only thing I've modified about it is the version tag of the image when I moved to the 7.0 SDK.

Also this is the upgrade commit for reference, both server and client upgraded to 2.2.1.

stavroskasidis commented 1 year ago

Please try using version 2.3.0-beta, it should be fixed. For more info see issue #36

stavroskasidis commented 1 year ago

Closing as it should be fixed with 2.3.0. Please reopen if you still have an issue.