Does js-ipfs have a readonly gateway server?

When I start my local ipfs node with “ipfs daemon”, in the cmd I get this:


With this, I can say and read files from IPFS.

In my Node.js app, when I run ipfs.create(), In the console I get something like this:

Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/

These are not readonly gateways. Does js-ipfs have a readonly gateway server? If yes, what is the readonly gateway in js-ipfs, or how can I find it? Or how can I configure it to be on whatever port I want?

I have found that the create() has config → Addresses → Gateway option, with the default on /ip4/

But while my app is running, if I try to read a file with, it doesn’t work, I get ERR_CONNECTION_REFUSED

I have found the answer. Yes, js-ipfs has a readonly gateway server, but it’s not starting implicitly togheter with the node, you have to use ipfs-http-gateway package. The package doesn’t really have good instructions, but here is how you do it. You import HttpGateway class from the package and give your ipfs instance to it as a constructor, then you call .start() from the HttpGateway instance. The .start() will take the config options from your ipfs instance, and will search for Adresses → Gateway options that defaults to /ip4/ and start the gateway to that port. You can read the code from the package where the HttpGateway class is written, and you’ll figure it all out.