Skip to content

Windows: redirect to *.ipfs.localhost fails in non-browser contexts #11024

@Rinse12

Description

@Rinse12
  • Repro steps

    1. Clone https://github.com/Rinse12/reproduce_kubo_windows_redirect_DNS_bug
    2. Run npm install
    3. Run npm run repro:windows from an Administrator-enabled shell on Windows; the script boots a temporary repo, then probes gateway redirects for /ipfs/<cid> (CIDv0 + CIDv1) and /ipns/<key>.
  • What happens

    • The script initializes a fresh repository, pins sample content, and publishes an IPNS record using the HTTP RPC API.
    • It then fetches three gateway URLs:
      • http://localhost:48180/ipfs/<cid-v0>
      • http://localhost:48180/ipfs/<cid-v1>
      • http://localhost:48180/ipns/<key>
    • Each fetch receives an HTTP redirect to the corresponding subdomain (<cid>.ipfs.localhost, <key>.ipns.localhost). Windows tries to resolve these hostnames through DNS, fails, and causes fetch to reject with TypeError: fetch failed. The script reports that the redirect-induced DNS failure occurred for all three cases.
  • Expected

    • The redirected hostname should resolve locally (as it does on Linux/macOS) so that the gateway response is delivered without DNS errors.
  • Observed output excerpt

    Using temporary IPFS_PATH: C:\Users\Administrator\AppData\Local\Temp\kubo-windows-redirect-repro-XXXXXX
    ...
    Generated IPNS key via RPC: k51qzi5uqu5dlmspjqtzeq0ejze6jbheg8ewrbr7bh6sd9a4u71qucvelqrp67
    Published IPNS record (allowOffline).
    Issuing fetch (CIDv0 gateway redirect): http://localhost:48180/ipfs/QmW8zGQpaiM2fcLGAZs4s33C9ooDtzHCLhYoLJC65YzHuQ
    
    ✅ CIDv0 gateway redirect: Successfully reproduced the redirect-induced DNS failure.
       fetch() followed the gateway redirect to http://bafybeidt4cryxmpqcyuqqxed6dsru2wqbtdse6c5nmtgzykiftm6glu6g4.ipfs.localhost:48180/ and Windows DNS
       could not resolve the ipfs.localhost subdomain of localhost.
    
    Issuing fetch (CIDv1 gateway redirect): http://localhost:48180/ipfs/bafybeidt4cryxmpqcyuqqxed6dsru2wqbtdse6c5nmtgzykiftm6glu6g4
    
    ✅ CIDv1 gateway redirect: Successfully reproduced the redirect-induced DNS failure.
       fetch() followed the gateway redirect to http://bafybeidt4cryxmpqcyuqqxed6dsru2wqbtdse6c5nmtgzykiftm6glu6g4.ipfs.localhost:48180/ and Windows DNS
       could not resolve the ipfs.localhost subdomain of localhost.
    
    Issuing fetch (IPNS gateway redirect): http://localhost:48180/ipns/k51qzi5uqu5dlmspjqtzeq0ejze6jbheg8ewrbr7bh6sd9a4u71qucvelqrp67
    
    ✅ IPNS gateway redirect: Successfully reproduced the redirect-induced DNS failure.
       fetch() followed the gateway redirect to http://k51qzi5uqu5dlmspjqtzeq0ejze6jbheg8ewrbr7bh6sd9a4u71qucvelqrp67.ipns.localhost:48180/ and Windows DNS
       could not resolve the ipns.localhost subdomain of localhost.
    
  • Additional notes

    • Running the identical script on Linux succeeds with HTTP 200, so the behavior is OS-specific.
    • The issue prevents programmatic use of the Windows gateway for IPNS names because the automatic redirect resolves to a hostname Windows cannot reach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: Likely tackled by core team if no one steps upeffort/hoursEstimated to take one or several hoursexp/expertHaving worked on the specific codebase is importantkind/bugA bug in existing code (including security flaws)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions