ipfs / ipfs-desktop

An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.
https://docs.ipfs.tech/install/ipfs-desktop/
MIT License
5.86k stars 850 forks source link

IPFS Scheme Handler Routes "ipfs://<hash>" to "http://127.0.0.1:8081/<hash>/" while it should route to "http://<hash>.ipfs.localhost:8081/" #2728

Open KillariDev opened 6 months ago

KillariDev commented 6 months ago

Describe the bug IPFS Scheme Handler Routes "ipfs://" to "http://127.0.0.1:8081//" while it should route to "http://.ipfs.localhost:8081/"

To Reproduce 1) Have Scheme handler installed with IPFS desktop 2) Go to Eg, ipfs://bafybeia3ly2pwdukzwufnof3utydapssmf3eco6sciylew3vd5rg55uxji on Firefox 3) Accept the dialog 4) Observe firefox opening page http://127.0.0.1:8081/bafybeia3ly2pwdukzwufnof3utydapssmf3eco6sciylew3vd5rg55uxji/ while it should go to http://bafybeia3ly2pwdukzwufnof3utydapssmf3eco6sciylew3vd5rg55uxji.ipfs.localhost:8081/ instead

welcome[bot] commented 6 months ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

whizzzkid commented 6 months ago

Thanks for submitting this issue @KillariDev, I see what you mean and I am not sure if this is a bug. This redirect happens based on this blob of code: https://github.com/ipfs/ipfs-desktop/blob/main/src/protocol-handlers.js#L19-L21. This ipfsd.gatewayAddr is the gateway multiaddr, which is /ip4/127.0.0.1/tcp/8081 in your case and the redirect happens as expected. However, this is not what you expected and that is understandable.

This behaviour is corrected by ipfs-companion which as the name suggests is a companion to ipfs implementations like kubo (that's what ipfs-desktop runs too). I didn't even notice this at first because I had the companion enabled.

However, I think this could be an additional feature, which allows overriding the gateway address to a custom address (localhost or a domain).