MediaTracker icon indicating copy to clipboard operation
MediaTracker copied to clipboard

Compability issue with NPMplus and empty Accept-Encoding header

Open ShrinkWrapper opened this issue 9 months ago • 4 comments

NPMplus sends an empty Accept-Encoding header upstream by default (proxy_set_header Accept-Encoding "";).

This causes runtime errors or incorrect asset delivery in applications that explicitly depend on Accept-Encoding to determine supported compression methods. The javascript and css in particular is getting error 500.

Would it be possible in future releases to add defensive checks defaulting to no compression in the header unless it is necessary.

const encoding = req.header('Accept-Encoding') || '';

if (encoding.includes('br')) {
  req.url = req.url + '.br';
  setHeaders();
} else if (encoding.includes('gz')) {
  req.url = req.url + '.gz';
}

ShrinkWrapper avatar Mar 12 '25 02:03 ShrinkWrapper