How can i fetch IPFS data from cid using fetch('ipfs://' + urlHash)

when i try to get data using fetch(‘https://ipfs.io/ipfs/’ + urlHash) then successfully able to get data …
but when try to get using
fetch(‘ipfs://’ + urlHash)
then it shows net::ERR_BLOCKED_BY_CLIENT

You have to have a gateway in your address. ipfs.io/ipfs is a public gateway. If you’re using a local node (on your computer) you still have to include the local node’s gateway address in your URL.

@ki4jgt Thanks for your response.

But when using ipfs.io/ipfs it is not fully decentralized. In brave and opera browser showing data without any gateway , like ipfs://hash in this format… isn’t is possible for fetch data

I think Opera uses the ipfs.io gateway in the background.

Brave can run a local node. In the end, ipfs://<cid> is more or less translated to http://127.0.0.1/ipfs/<cid>, which is the local ipfs daemon gateway.

The IPFS Companion browser extension intercepts ipfs:// and does the magic for you, but not sure it works from JS for fetch.

1 Like

Brave will resolve ipfs://CID using whichever gateway is configured in the settings. There is no requirement to start the built-in IPFS node. The default gateway is dweb.link, but any public gateway can be used. However, it’s probably a better idea to start the local built-in node in order to lower the bandwidth used by the public gateways.

Screenshot of configurable settings…

1 Like

@ipfsme this is very surprising to me.

Looking at the documentation it looks like the gateway is not supposed to be used for production apps: IPFS Gateway | IPFS Docs

Do they have some special deal with protocol labs to help spread adoption?