ipfs / dir-index-html

Directory listing HTML for go-ipfs gateways
MIT License
38 stars 55 forks source link

Broken CID column on DNSLink gateway #42

Closed lidel closed 4 years ago

lidel commented 4 years ago

There is a problem when directory listing happens on DNSLink gateway (website under own domain name, backed by go-ipfs+DNSLink)

How to reproduce

To illustrate, if I render HTML like this (with go-ipfs 0.7.0):

$ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8080/go-ipfs/v0.7.0"

The breadcrumbs are broken:

          Index of
          /ipns/<a href="/ipns/dist.ipfs.io">dist.ipfs.io</a>/<a href="/ipns/dist.ipfs.io/go-ipfs">go-ipfs</a>/<a href="/ipns/dist.ipfs.io/go-ipfs/v0.7.0">v0.7.0</a>

Links under filenames are ok, but direct links to CID under truncated CIDs are broken:

        <td>
          <a href="/go-ipfs/v0.7.0/go-ipfs_v0.7.0_windows-amd64.zip.sha512">go-ipfs_v0.7.0_windows-amd64.zip.sha512</a>
        </td>
        <td class="no-linebreak">

          <a class="ipfs-hash" href="/ipfs/QmZwRgWU2St6St7bQi1uAh2j6EQHEJsTxuY7igVDi3dY1h">
            QmZw…dY1h
          </a>

This is because the /ipfs/... gateway is not mounted under DNSLink hostnames. That is why attempt to load content path will fail:

$ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8080/ipfs/QmZwRgWU2St6St7bQi1uAh2j6EQHEJsTxuY7igVDi3dY1h"
HTTP/1.1 404 Not Found

TLDR

Good news is that the main link under filename continue to work, what is broken is this newly added CID column Its broken on DNSLink websites such as https://dist.ipfs.io/go-ipfs/v0.7.0 (when loaded without redirect to local gateway).

How to fix