There are 2 options and we need to prioritise rules between each other
Redirect IPFS resources to the configured IPFS gateway
Automatically redirect to IPFS pages via DNSLink when possible
If (1) is enabled, we detect /ipfs/{cid} in URL, confirm {cid} is a real CID, and if so, redirect that to ipfs://{cid} (local node) or https://dweb.link/ipfs/{cid} (gateway).
If (2) is enabled, we either do DNSLink lookup for every domain name (only if server returned 5xx error codes), or only if x-ipfs-path is present. If we confirm DNSLink is present (we only care about its presence, not its value), then we redirect to ipns://{example.com} (local node) or https://dweb.link/ipns/{example.com}(gateway), and IPFS node will resolve DNSLink and load the correct data internally.
if we have both (1) and (2) enabled then links like https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR that have both both /ipfs/{cid} resources and a DNSLink, the logic from (1) should take a priority and we have to end up on http://localhost:48080/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
There are 2 options and we need to prioritise rules between each other
Redirect IPFS resources to the configured IPFS gateway
Automatically redirect to IPFS pages via DNSLink when possible
If (1) is enabled, we detect
/ipfs/{cid}
in URL, confirm{cid}
is a real CID, and if so, redirect that toipfs://{cid}
(local node) orhttps://dweb.link/ipfs/{cid}
(gateway). If (2) is enabled, we either do DNSLink lookup for every domain name (only if server returned 5xx error codes), or only ifx-ipfs-path
is present. If we confirm DNSLink is present (we only care about its presence, not its value), then we redirect toipns://{example.com}
(local node) orhttps://dweb.link/ipns/{example.com}
(gateway), and IPFS node will resolve DNSLink and load the correct data internally.Test cases:
https://blog.ipfs.io/24-uncensorable-wikipedia -> ipns://blog.ipfs.io/24-uncensorable-wikipedia
https://en.wikipedia-on-ipfs.org/wiki/Wikipedia/ -> ipns://en.wikipedia-on-ipfs.org/wiki/Wikipedia/
if we have both (1) and (2) enabled then links like
https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
that have both both/ipfs/{cid}
resources and a DNSLink, the logic from (1) should take a priority and we have to end up on http://localhost:48080/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR