I have a Node.js app running ipfs-core
, and on that app I spawn a local gateway server with ipfs-http-gateway. This is my configuration and spawning of the node:
import { create } from 'ipfs-core';
const IPFS = (() => {
let IPFSInstance = undefined;
const createInstance = async () => {
return await create({
config: {
Addresses: {
Gateway: '/ip4/127.0.0.1/tcp/9090',
},
},
});
};
return {
getInstance: async () => {
if (!IPFSInstance) IPFSInstance = await createInstance();
return IPFSInstance;
},
};
})();
export default IPFS;
And this is how I spawn the gateway server somewhere else in my app:
import { HttpGateway } from 'ipfs-http-gateway';
import IPFS from './create-ipfs.js';
const ipfs = await IPFS.getInstance();
const IpfsHttpGateway = new HttpGateway(ipfs);
IpfsHttpGateway.start(ipfs);
The server spawns, and I can see it bind with port 9090. If I take a CID like the one at the bottom of this page (the CID is: QmWCscor6qWPdx53zEQmZvQvuWQYxx1ARRCXwYVE4s9wzJ) which is a file with a text “You did it!” and call the local gateway server spawned by my app in my browser like this: localhost:9090/ipfs/QmWCscor6qWPdx53zEQmZvQvuWQYxx1ARRCXwYVE4s9wzJ
, I get the file. But if from another node, I add a file with IPFS Desktop for example, I can get the file through a public gateway server like ipfs.io, but I cannot get it through the local gateway server spawned by my app. Shouldn’t the local gateway server work with all CID’s? What am I doing wrong?