I find that the major way js-ipfs transferring data is through preload nodes hosted on ipfs dot io
Is there any way to host my own preload nodes in case that the ipfs dot io nodes become unstable?
Yes.
-
Setup a go-ipfs node on a server, like https://blog.ipfs.io/22-run-ipfs-on-a-vps/ or on your own machine.
-
Connect your js-ipfs node to your go-ipfs server via websocket, such as
await node.swarm.connect(multiaddr);
wheremultiaddr
is/dns4/yourserver.com/tcp/443/wss/p2p/QmYourPeeridHash
-
Fetch the content (goto the URL, use
fetch
, usecURL
, whatever you please) -
The content will be available on other gateways shortly after that as go-ipfs does its magic across the globe.
and then POST https://preload.server.com/api/v0/refs?r=true&arg=bafy… from js-ipfs