Skip to content

fix(npm): use combined Accept header to support Artifactory upstreams - #241

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
pgarbe:fix/npm-combined-accept-header
Aug 10, 2026
Merged

fix(npm): use combined Accept header to support Artifactory upstreams#241
andrew merged 1 commit into
git-pkgs:mainfrom
pgarbe:fix/npm-combined-accept-header

Conversation

@pgarbe

@pgarbe pgarbe commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Why

  • JFrog Artifactory (and similar upstreams) return HTTP 406 when the npm client sends only the abbreviated packument content type (application/vnd.npm.install-v1+json), breaking package metadata lookups entirely.
  • Sending a combined Accept header with a quality-factor fallback (application/json;q=0.8) lets the proxy work with both the official npm registry and stricter upstreams without sacrificing the bandwidth benefit for registries that do support the abbreviated format.

What

Changed the default Accept header for npm package metadata requests from the abbreviated-only type to a combined header that prefers the smaller format but gracefully falls back to full JSON, leaving the cooldown path unchanged (it still requests full metadata exclusively).

Closes #228

When cooldown is disabled, send:
  Accept: application/vnd.npm.install-v1+json;q=1.0, application/json;q=0.8

This allows upstreams like JFrog Artifactory that return 406 for the
abbreviated packument type to fall back to full JSON metadata, while
letting the public npm registry continue to serve the smaller
abbreviated format it prefers.

When cooldown is enabled, keep sending only application/json because
the abbreviated format omits the "time" map required for version age
filtering.

Fixes git-pkgs#228

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pgarbe
pgarbe force-pushed the fix/npm-combined-accept-header branch from 52b5d42 to ced83df Compare August 10, 2026 07:12
@pgarbe
pgarbe marked this pull request as ready for review August 10, 2026 07:12
@andrew
andrew merged commit 14f80ce into git-pkgs:main Aug 10, 2026
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

Successfully merging this pull request may close these issues.

npm: decouple upstream Accept header choice from cooldown configuration

2 participants