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

Detecting and Using IPFS Desktop Node #25

Closed
logasja opened this issue Sep 11, 2020 · 1 comment
Closed

Detecting and Using IPFS Desktop Node #25

logasja opened this issue Sep 11, 2020 · 1 comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature

Comments

@logasja
Copy link

logasja commented Sep 11, 2020

I ran into this same issue recently when developing an extension with IPFS in the backend. CORS will not allow the http api to talk to the desktop daemon. I fixed this in my extension by changing the source of the request, but this involved capturing the request before it was sent. Anyone found a workaround?

@lidel lidel added the kind/enhancement A net-new feature or improvement to an existing feature label Sep 15, 2020
@lidel
Copy link
Member

lidel commented Sep 15, 2020

Present

AFAIK there is no workaround.

API is very powerful and you don't want random websites to manage your node. Regular browser context respects CORS, so you need to explicitly safelist Origins that are allowed to talk to the API via Access-Control-Allow-Origin header:

$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["https://origin-you-want-to-safelist.example.com", "http://127.0.0.1:5001"]'

If you run JS in a browser extension, then just like you said, one can override Origin via webRequest API because browser extensions are privileged contexts. Regular browser context does not have that API, so CORS is the only way to make it work.

Future

We want to make local IPFS node useful for websites without giving full access to the API (meta issue: ipfs/in-web-browsers#158), but that requires figuring out more flexible access controls for the API (ipfs/kubo#1532), or creating something else, tailored specifically for use on the web.

@logasja logasja closed this as completed Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants