Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#98 Self Hosting #216

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

KevinSheedy
Copy link

I've published a #98 Self Hosting version of unpkg to npm here:
https://www.npmjs.com/package/unpkg-server

I've been running it in my own organisation against a private npm registry (nexus) and it seems pretty stable.

These are the changes I used to produce a version of server.js that can be configured using a few CLI flags.

I've changed the build process a bit which I'm sure would break the unpkg build process, so this PR is primarily to discuss the approach and what would need to change before this could potentially be merged.

  • Added a flag to disable the integration with cloudflare: ENABLE_CLOUDFLARE
  • Moved several process.env options to be read at runtime instead of at build time
  • Added a CLI library minimist for reading/setting config flags
  • Documented the available configuration options
  • Support for ports other than 443
  • Updated package.json to support publishing to npm

@timomayer
Copy link

@mjackson will you merge this branch? @KevinSheedy thanks a lot!

@mikebridge
Copy link

mikebridge commented Jan 30, 2020

@KevinSheedy I'm testing this against a local npm repository and I'm getting an authentication error:

NPM_REGISTRY_URL=https://admin:********@localhost:6984/registry

node node_modules/unpkg-server/server.js \
     --DEBUG=true \
     --ORIGIN=http://1.2.3.4 \
     --NODE_TLS_REJECT_UNAUTHORIZED=0 \
     --NPM_REGISTRY_URL=$NPM_REGISTRY_URL \
     --PORT=8081
unpkg-server v0.0.4
Server listening on port 8081, Ctrl+C to quit
Fetching package info for @mikebridge/mb-test-package from https://admin:********@localhost:6984/registry/@mikebridge%2Fmb-test-package
Error fetching info for @mikebridge/mb-test-package (status: 401)
{"error":"unauthorized","reason":"Authentication required."}

I'm confused because the url that shows up in the debug message works from curl:

curl -k https://admin:********@localhost:6984/registry/@mikebridge%2Fmb-test-package
=> 
{"_id":"@mikebridge/mb-test-package","_rev":"6-7769cf0820e2bee4746ed5f77a50c524","name":"@mikebridge/mb-test-package","time":{"modified":"2020-01-30T19:09:27.532Z","created":"2020-01-30T18:07:41.575Z","1.0.1":"2020-01-30T18:07:41.575Z","1.0.2":"2020-01-30T18:14:06.698Z","1.0.3":"2020-01-30T19:09:27.532Z"} ... 

@mikebridge
Copy link

I switched from running straight-up couchdb to serving it from verdaccio and this fixes my issue.

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.

3 participants