Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Configurable http.request protocol option #66

Closed
ckeenan opened this issue Sep 25, 2015 · 7 comments · Fixed by #67
Closed

Configurable http.request protocol option #66

ckeenan opened this issue Sep 25, 2015 · 7 comments · Fixed by #67

Comments

@ckeenan
Copy link
Contributor

ckeenan commented Sep 25, 2015

Running ipfs-api from an on-disk "file:///.../index.html" does not work. Calling http.request without passing a protocol in the opts, it will default to window.location.protocol. This causes the following error:
TypeError: Failed to execute 'fetch' on 'Window': Failed to parse URL from file://127.0.0.1:5001/api/...

see dist/ipfsapi.js:5837

Could we add a way to explicitly set this protocol option? It could be passed as an opt in the requestAPI or included as a param of IpfsAPI. The latter might be preferable for this scenario so not to require a protocol opt for every method.. maybe it could be IpfsAPI(host_or_multiaddr, port, opts)?

@jbenet
Copy link
Contributor

jbenet commented Sep 25, 2015

Ahh i see. yeah we should.

@slothbag
Copy link

Same problem here. I cherry-picked the protocol line out of ckeenans PR and was able to get it working, thanks ckeenan, would be great for this to be merged.

@fbaiodias
Copy link
Contributor

Same problem here as well.

I'm trying to run ipfs-api inside a chrome extension and need to specify the protocol, because it defaults to chrome-extension://.

@fmarts
Copy link

fmarts commented Nov 16, 2015

👍 would love to see it merged

@dignifiedquire
Copy link
Contributor

Is this still an issue with the latest version? (We switched to request and pass http in the url)

@fbaiodias
Copy link
Contributor

Yes, only could get it working when I forced the protocol to http.

@dignifiedquire
Copy link
Contributor

@xicombd okay thanks, strange though as I would expect request to take the protocol from the uri

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants