Windows: redirect to `*.ipfs.localhost` fails in non-browser contexts
- Dominant language
- Go
- Stars
- 17.1k
- Forks
- 3.2k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 11
Description
- **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/` (CIDv0 + CIDv1) and `/ipns/`.
- **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/`
- `http://localhost:48180/ipfs/`
- `http://localhost:48180/ipns/`
- Each fetch receives an HTTP redirect to the corresponding subdomain (`.ipfs.localhost`, `.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.
Contributor guide
Assessment
This issue has not been assessed yet.