Question

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.

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top