Hello @Fredrik Rönnehag ,
I understand that you have an azure app service and an Azure CDN in front of it and when trying to load the next assets like js and css files, you receive an ERR_HTTP2_PROTOCOL_ERROR.
You can refer the below thread for more details on how to find the root cause of the issue:
https://learn.microsoft.com/en-us/answers/questions/1338000/http2-protocol-error-with-azure-cdn
I requested you to perform a CURL on your origin URL which is resulting in error.
- In case you receive HTTP 206 in the curl (same as the above thread), then you need to follow the workaround mentioned in the above thread.
- If you receive HTTP 200, then share the results (masking the origin URL), so that I can investigate further.
You did a CURL to the origin and received 200 OK, but the results didn't have the details I needed, so requested you to do a CURL again using the below command and reshare the results:
curl.exe -v -o nul --range "0-8000000" -H "Accept-Encoding: gzip" "https://abcdomain.azureedge.net/assets/index.js"
You came back with an update stating you found the issue as below:
On the express server you still had a reference to server.use(compression()) and after you removed this, it started working.
You think it had something to do with the request being sent to accept gzip and br.
This error is possible if the content is being double compressed, and the browser can't decompress the file.
If the content is being compressed at the backend and compression is also enabled in the CDN, it is recommended to change it to not compress the files at the backend before serving them.
There are two ways to enable file compression:
- Enable compression on your origin server. In this case, Azure CDN passes along the compressed files and delivers them to clients that request them.
- Enable compression directly on the CDN POP servers (compression on the fly). In this case, the CDN compresses the files and serves them to the end users, even if they don't get compressed by the origin server.
You shouldn't enable compression on both origin and CDN.
Refer: https://learn.microsoft.com/en-us/azure/cdn/cdn-improve-performance#compression-rules
When you disabled all compression on the express server and enabled it in the CDN instead, it started working.
Kindly let us know if the above helps or you need further assistance on this issue.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.