Infura Dedicated Gateway Not working

Dear Team -
I have been using Infura IPFS for some time now, but recently, I am struggling with the following issues

My code below

const projectId = '2DA.......';

const projectSecret = '1ff........';

const auth = 'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64');

  const ipfs = await IPFS.create({
    host: 'myipfsat.infura-ipfs.io', port: 5001, protocol: 'https', apiPath: '/api/v0', headers: {
      authorization: auth,
    },
  })
  // console.log("ipfs value is", ipfs)
  try {
    const CID = await ipfs.add(n)
    console.log('cid is ', CID, CID.path)
    const url = `https://ipfs.io/ipfs/${CID.path}`
    console.log("url is ", url)
    return url;
  } catch (error) {
    console.log("error", error)
  }

Content is pushed and CID showing the response in the log, but when I try to access the same. it shows “Invalid CID”

https://myipfsat.infura-ipfs.io/ipfs/api/v0/QmefeRkKahCUAWpb7iQns8NH3FJ8CmwXdMm9e4E79UXMF6

please note, i am using following package in the nodejs server.

import * as IPFS from ‘ipfs-core’;

Also I tried using host as “ipfs.infura.io” … still the same issue.

1 Like

Hi @LogeswaranA ,

Once you get your CID you should be able to access it via your Infura IPFS dedicated gateway in the following way:
https://your_dedicated_gateway_name.infura-ipfs.io/ipfs/CID

I am not very familiar with the ipfs-core package but it seems to me that when using it you are also running your own node and the propagation of the CID in the p2p network depends on the number of your peers.

Are you able to access your CID using the ipfs.io gateway? as you have defined your url const? If not, this might mean that the content is not yet propagated p2p.

https://ipfs.io/ipfs/QmefeRkKahCUAWpb7iQns8NH3FJ8CmwXdMm9e4E79UXMF6

Should you want to switch to the ipfs-http-client javascript library we have quite a few examples of using it in our Support Tips category. Below I will paste just a few:

1 Like

Thanks for the quick reply!, yes ofcourse I was able to see that using ipfs.io/ipfs/CID… but after sometime, it was not showing the same.

My requirement is to push the file image from the server to IPFS, that’s the reason I was using ipfs-core. I attempted to use ipfs-http-client, but it was throwing 403 forbidden issue.

Any direction on how to overcome this would let me use the ipfs-http-client at server side.

thanks for the support

1 Like

You are welcome.
403 Forbidden response status code indicates that the server understands the request but refuses to authorize it.
What is the version of the ipfs-http-client you used? also can you share a snippet of the code used with ipfs-http-client, containing the way you defined your credentials and auth as well?

1 Like
"ipfs-http-client": "^56.0.2",

Version of the packge I used…

I authenticated like below… Same stuff works fine with “ipfs” package, but not letting me view, but in the case of ipfs-http-client it shows origin error.

Do we have any sample repository to work with nodejs + ipfs?.. Kindly assist.

const projectId = '2DA.......';

const projectSecret = '1ff........';

const auth = 'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64');

  const ipfs = await IPFS.create({
    host: 'myipfsat.infura-ipfs.io', port: 5001, protocol: 'https', apiPath: '/api/v0', headers: {
      authorization: auth,
    },
  })
  // console.log("ipfs value is", ipfs)
  try {
    const CID = await ipfs.add(n)
    console.log('cid is ', CID, CID.path)
    const url = `https://ipfs.io/ipfs/${CID.path}`
    console.log("url is ", url)
    return url;
  } catch (error) {
    console.log("error", error)
  }
1 Like

My suggestion is to upgrade to the latest version of ipfs-http-client (59.0.0) and try again one of the examples I shared in my last reply using nodejs and ipfs-http-client.

Regarding the ipfs-core package, at the moment I don’t have a working example of it being used with infura. Reading thru the documentation it seems that it is a lighter version of the ipfs client without the cli.

When using it a local ipfs node will start and that’s why when adding some content you receive a CID. The p2p propagation of that CID in the ipfs network depends on the number of peers your local node has, that’s why sometimes it is available and on the ipfs.io gateway and sometimes it is not.

I have tried using the same parameters when authenticating and creating the ipfs client, below, as I would do when using the ipfs-http-client in order to upload through an Infura node, but it seems that this info is neglected somehow by the ipfs-core package and the upload is done through the local node.

const auth =
    'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')
    const ipfs = await IPFS.create({
        host: 'ipfs.infura.io',
        port: 5001,
        protocol: 'https',
        headers: {
          authorization: auth
        }
      })