-
Notifications
You must be signed in to change notification settings - Fork 299
version forbidden ? #855
Comments
the check for "local" access here is only looking for empty referrer/origin, so you may need to configure CORS like
but... the other requests in this context work? |
I don't know if other requests work - when it fails the "version" test, it assumes there is no usable local ipfs instance, falls back and loads js-ipfs instead of js-ipfs-api. I'm assuming any other request from the browser is also going to fail if it calls the same "allowOrigin()" function. I can't follow the Go code enough to understand where cfg.AllowedOrigins is coming form, but I may be able to figure out how to get this to work with the Docker-based IPFS instance we'll use for dweb-mirror, but that is far from the only case where I'd expect an ideal browser app (or an extension) to check for a local ipfs instance before starting up a JS-IPFS client so that we get the cross-page and cross-visit to the site caching. |
ok, that makes a lot more sense (re: other calls not working), otherwise this would have been a mystery :) in that case you just need to configure CORS as indicated here: https://github.com/ipfs/js-ipfs-api#cors localhost should arguably be included in default CORS (just like the hardcoded check for local curl), I'll open an issue for that |
I think @parkan has answered this, CORS prevents Shout if that didn't fix it for you @mitra42. |
I haven't been able to test this yet, if it works it will fix one (of three) cases we are interested in, where we have installed the local ipfs daemon ourselves. In dweb-mirror we plan on distributing a docker with an http image and either an integrated, or a separate docker with IPFS. It doesn't currently fix that case because I can't figure out how to set config variables on a docker-based IPFS, since the "ipfs config" line only works AFTER start_ipfs is run (i.e. after the container is operating), so-far I haven't been able to figure out how to set them in the downloadable docker image before IPFS is running. This also doesn't handle the case of a browser app (such as dweb.archive.org) optimising for the case where another instance of IPFS is running locally. This is what we'd like to do with dweb.archive.org so that if you run a local daemon we take advantage of the speed improvement from a local IPFS caching across runs of the browser. This might make up for some of the speed hits we take by including IPFS. Unfortunately that isn't going to work since its unlikely the user will have done the workaround @parkan suggests. Anyway, as @parkan says, allowing any localhost port should probably be the default, its unclear to me why CORS (which blocks where a webpage is loaded from) is being used to block api requests, rather than basing it on the IP where the request is coming from. |
can discuss that offline
this is a reasonable security policy and applies to any kind of local HTTP API, not just IPFS: imagine arbitrary websites being able to run commands against your local servers, potentially leaking private data IPFS companion has per-site access policies that are presented in a friendly UI and will probably be the best way to allow web<>local IPFS access for the immediate future |
OK - understood re security issue, so looks like local config is going to be needed before can use js-ipfs-api. But note @parkan see https://github.com/protocol/collab-internet-archive/issues/55#issuecomment-422075488 ,for why that docker suggestion doesn't actually work. |
I can confirm that adding the two line @parkan suggested works to allow the API to work. It looks like the docker issue above, will stop it working in docker for now, though that presumably is fixable. Of course, the more general issue is the bizareness of using the location from which content was loaded as the security test in a content-addressed file system ! Which means that an application downloaded via a HTTP server, or even fetched through IPFS won't be able to use a local IPFS server to ensure persistence, but I guess that is a topic for elsewhere since @alanshaw has closed this issue :-( |
For anyone reading this later ... the solution for the docker case is to run
|
i dont know why but these config setting commands
|
I'm seeing an issue with the js-ipfs-api where "version" is forbidden.
Its unclear to me if this is a JS-IPFS-API issue or a GoLang daemon issue?
I call
ipfs.version
and see in the console.log :Request headers are:
and Response is:
Running
ipfs -D daemon
generates the following debugging:The text was updated successfully, but these errors were encountered: