简体   繁体   中英

Getting package description from NPM via browser

I'm trying to write a Chrome Web App which will read information from NPM. Chrome obeys the Access-Control-Allow-Origin flags on websites, which is causing me some problems.

While I can read the following URL:

http://registry.npmjs.org/simple-js/-/simple-js-0.1.5.tgz

because it has access-control-allow-origin: * in the headers, I can't load this URL:

http://registry.npmjs.org/simple-js

Which is the one I need to actually find out what the latest version is (and hence find out the above URL).

Any ideas? Is there a URL that I could access in order to find the same data?

Note: This is an app to read package info from NPM. I don't want to precompile NPM packages into it.

With Chrome Web Apps, you can set the manifest file to ignore the same-origin policy. You can see this document: https://developer.chrome.com/extensions/xhr

That is the easiest solution I can think of. Alternatively, you may download the tgz file and decompress it on the client, or you can create a proxy to retrieve the JSON file (a web page that downloads the file and sends it back to the client with the appropriate headers).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM