Precompressed Brotli File in Workers Static Asset is not decompressed properly

Previously I have been putting .js.br file in Cloudflare Pages (React+Vite, linked to git and run build script in Pages) I'm migrating to Workers, but when I put the same file in public folder, even with _headers (same as when using Pages) set to:
/WebGL/Build/*.js.br
Content-Encoding: br
Content-Type: application/javascript
/WebGL/Build/*.js.br
Content-Encoding: br
Content-Type: application/javascript
when the file is fetched, I get jumbled Response instead of the normally decompressed js file. The Response Headers have the content-encoding : br and content-type : application/javascript wrangler.jsonc:
"assets": {
"not_found_handling": "single-page-application",
"directory": "./dist/client",
"binding": "ASSETS",
"run_worker_first": [ "/api/*" ]
},
"assets": {
"not_found_handling": "single-page-application",
"directory": "./dist/client",
"binding": "ASSETS",
"run_worker_first": [ "/api/*" ]
},
In the local environment the file works. Not sure what I'm missing here. Thanks in advance! Edit: It seems the one in Pages has "Content-Length" header, while in workers there isn't any. Is there a way to ensure there is one?
No description
4 Replies
Walshy
Walshy12h ago
I'm a little confused, you're requesting a Brotli file and getting Brotli back with the appropriate content-encoding header. That sounds correct?
Ampere
AmpereOP11h ago
Yes, but I'm using Unity so it seems that Content-Length header is also required. When I was using Pages it was there. Usually the response in Network tab is already decompressed. Then I'd get
Unable to parse /WebGL/Build/build.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug.
Unable to parse /WebGL/Build/build.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug.
Walshy
Walshy10h ago
Can you share the url to test? Content-Length is generally not there for compressed content (which is fully spec compliant) That error seems to just want CE br which you have Chrome should be decompressing it though so wonder if it's actually bad data...
Ampere
AmpereOP5h ago
url sent in DM

Did you find this page helpful?