esm-dev / esm.sh

A fast, smart, & global CDN for modern(es2015+) web development.
https://esm.sh
MIT License
3.07k stars 147 forks source link

Self hosted - 405 Response using the npm.pkg.github.com registry #821

Closed GianlucaGuarini closed 5 months ago

GianlucaGuarini commented 5 months ago

Hi there, I am using a self-hosted instance of esm.sh pointing to the github registry.

However anytime I try to load a package I get always the same response:

hrow new Error([esm.sh] npm: could not get metadata of package '@my-org/my-package' (405 Method Not Allowed: ));

Is there anything special that I need to tweek in my config?

{
  "port": 8080,
  "workDir": "/path/to/workdir",
  "storage": "local:/path/to/storage",
  "npmRegistryScope": "@my-org",
  "npmRegistry": "https://npm.pkg.github.com",
  "npmToken": "xxx"
}

Note that with curl everything works just fine:

curl -H "Authorization: Bearer xxx" https://npm.pkg.github.com/@my-org/my-package

Thank you for this awesome project!

GianlucaGuarini commented 5 months ago

It seems that commenting out [this condition] fixed the issue https://github.com/esm-dev/esm.sh/blob/c53728201b3592017ecc6532221b529f00b4e668/server/npm.go#L252-L254)

So I guess that the github registry doesn't use the same npm registry paths

ije commented 5 months ago

It seems that commenting out [this condition] fixed the issue

https://github.com/esm-dev/esm.sh/blob/c53728201b3592017ecc6532221b529f00b4e668/server/npm.go#L252-L254

) So I guess that the github registry doesn't use the same npm registry paths

yes! seems GitHub doesn't support URL 'https://npm.pkg.github.com/pkg/1.0.0', would you like to create a PR? or i will fix it later. thanks 💯

GianlucaGuarini commented 5 months ago

would you like to create a PR? or i will fix it later. thanks 💯

You are welcome :)