service-worker-gateway icon indicating copy to clipboard operation
service-worker-gateway copied to clipboard

Do not lose information about HTTP provider if https:// URL is pasted

Open agmap opened this issue 5 months ago • 5 comments

When fetching content with an IPFS gateway URL (https://{gateway-URL}/ipfs/{CID}/{optional path to resource}) I would like this gateway URL to be automatically appended to the end of the recursive fallback gateway list. This way I can retrieve the content if all other direct retrievals and inbrowser.link fail. It is justifiable because the new gateway is created by the user URL input.

The same would also be desirable in helia-verified-fetch.

agmap avatar Jul 21 '25 11:07 agmap

This seems to overlap a bit with the idea of dynamically encoded providers: https://github.com/ipfs/helia-verified-fetch/pull/242

2color avatar Jul 21 '25 15:07 2color

More to the background. Many NFTs and DID URLs have URI with IFPS gateway URL and not in neutral format ipfs://{CID}. To fetch the URI of the NFT I just take the NFT URI and pass it in service worker gateway or using helia-verfied-fetch which fetch the content verifiable and trustless directly from the providers. Sometimes its not possible to fetch the content, but is available on the gateway of the NFT URI, which is not in the default fallback recursive gateway list.

Alternatively when helia fetch fails, I could fetch the content using the NFT URI without using helia-verified-fetch or add this gateway in the list of recursive gateway. But this always need action to be done. But I would really like, it automatically loads in service worker gateway and helia-verfied-fetch, without adding parameters or changing the IPFS URL, .... I don't know if that PR, you mentioned, helps in that case.

It was just an idea of mine. If it doesn't make sense, then please feel free to close this request so that everything doesn't overflow.

agmap avatar Jul 21 '25 18:07 agmap

That makes sense, I think this issue has merit on it's own based on your use case

SgtPooki avatar Jul 23 '25 00:07 SgtPooki

Triage note:

  • @agmap could you elaborate on the UX you expect?
    • Where are you entering https://{gateway-URL}/ipfs/{CID}/{optional path to resource} ? Into input at https://inbrowser.link ?
      Image
    • Is your expectation that when you do that the gateway-URL is "added automatically to this list" (in practice, we dont want to do it permanently, but just for the retrieval session context related to the root cid -- in practice the same, due to origin isolation, but noting to be formally correct)?
      Image
  • Ask to not lose information about "one potential working HTTP provider" when passing HTTP gateway URLs tro verified-fetch is sensible, but probably should happen in https://github.com/ipfs/helia-verified-fetch

Right now, we are unsure what is the ask here.

lidel avatar Oct 21 '25 14:10 lidel

Yes, when I enter a direct gateway url like https://gateway.pinata.cloud/ipfs/bafybeidfmcgmrpfrfpmrx7swrwlon7ul4bqv4k6hoaedqotdu22psni5ae

Image

The gateway should automatically temporary added to the Recursive Gateways List for loading the CID. (not permanently, only for the season for loading this CID)

Image

This way, the CID is loaded even if the CID is not announced on IPNI or IPNI has an outage.

The same should be internally done by helia/verified-fetch. When I pass a gateway url the gateway should also automatically used in gateways for fetching the CID. (The gateway should also not permanently added, only for the season for loading this CID)

import { createVerifiedFetch } from '@helia/verified-fetch'

const fetch = await createVerifiedFetch({
  gateways: ['https://trustless-gateway.link', 'https://gateway.pinata.cloud' ],
  routers: ['http://delegated-ipfs.dev']
})

const resp = await fetch('https://gateway.pinata.cloud/ipfs/bafybeidfmcgmrpfrfpmrx7swrwlon7ul4bqv4k6hoaedqotdu22psni5ae')

const json = await resp.json()

agmap avatar Oct 21 '25 15:10 agmap