Skip to content

Commit 291c418

Browse files
authored
docs: update address-ipfs-on-web.md
removed some legacy examples which predate subdomain gateways and native protocol handler work in brave
1 parent 8acfb43 commit 291c418

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

docs/how-to/address-ipfs-on-web.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ description: Hands-on guides to using and developing with IPFS to build decentra
55

66
# Address IPFS on the web
77

8-
How to link to content on IPFS.
8+
How to link to content on IPFS with HTTP URL:
99

1010
```shell
1111
https://ipfs.io/ipfs/<CID>
1212
# e.g
13-
https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu
13+
https://ipfs.io/ipfs/bafybeihkoviema7g3gxyt6la7vd5ho32ictqbilu3wnlo3rs7ewhnp7lly
1414
```
1515

16-
Browsers that support IPFS can redirect these requests to your local IPFS node, while those that don't can fetch the resource from the ipfs.io gateway.
16+
Clients that support IPFS can ignore HTTP details and retrieve data natively, while those that don't can fetch the resource from HTTP server at `ipfs.io` gateway.
1717

18-
You can swap out `ipfs.io` for your own http-to-ipfs gateway, but you are then obliged to keep that gateway running _forever_. If your gateway goes down, users with IPFS aware tools will still be able to fetch the content from the IPFS network as long as any node still hosts it, but for those without, the link will be broken. Don't do that.
18+
Thanks to CID, one can swap out `ipfs.io` for [self-hosted local gateway](https://docs.ipfs.io/install/). When `ipfs.io` or any other [public gateway](https://ipfs.github.io/public-gateway-checker/) goes down, IPFS aware clients will still be able to fetch the content from the IPFS network as long as at least one node still provides the data behind the CID to the network.
1919

2020
## Dweb addressing in brief
2121

2222
- In IPFS, addresses (for content) are path-like; they are components separated by slashes.
2323
- The first component is the protocol, which tells you how to interpret everything after it.
2424
- Content referenced by a hash might have named links. (For example, a Git commit has a link named `parent`, which is really just a pointer to the hash of another Git commit.) Everything after the CID in an IPFS address is those named links.
2525
- Since these addresses aren’t URLs, using them in a web browser requires reformatting them slightly:
26-
- Through an HTTP gateway, as `http://<gateway host>/<IPFS address>`
27-
- Through the gateway subdomain (more secure, harder to set up): `http://<cid>.ipfs.<gateway host>/<path>`, so the protocol and CID are subdomains.
28-
- Through custom URL protocols like `ipfs://<CID>/<path>`, `ipns://<peer ID>/<path>`, and `dweb://<IPFS address>`
26+
- Through a [path gateway](#path-gateway), as `https://<gateway-host>/ipfs/<cid>/<path>`
27+
- Through a [subdomain gateway](#subdomain-gateway) (more secure, harder to set up): `https://<cid>.ipfs.<gateway-host>/<path>`, for hosting websites with Origin isolation
28+
- Through native protocol handlers like `ipfs://<cid>/<path>`, `ipns://<ipns-name>/<path>`, when we don't want to hard-code a specific HTTP gateway in the URI
2929

3030
## HTTP gateways
3131

@@ -37,22 +37,14 @@ HTTP gateways have worked well since 2015, but they come with a significant set
3737

3838
### Protocol upgrade
3939

40-
Tools and browser extensions should detect IPFS content paths and resolve them directly over IPFS protocol. They should use HTTP gateway only as a fallback when no native implementation is available in order to ensure a smooth, backward-compatible transition.
40+
Long term, deserialized responses returned by a public HTTP gateway aim to be used only as a fallback when no native implementation of IPFS is available.
4141

42-
::: tip
43-
Use relative or absolute URLs that include content-addressed paths. This will take advantage of content addressing today while ensuring backward compatibility with the legacy web.
44-
45-
For example, a website can load static assets from content-addressed paths:
42+
IPFS clients, user agents, tools and extensions should detect CIDs in URLs, DNSlinks or IPFS content paths and resolve them directly over IPFS protocol (ensuring the retrieved data match the expected hash).
4643

47-
```
48-
<link rel="stylesheet" href="https://example.com/ipfs/QmNrgEMcUygbKzZeZgYFosdd27VE9KnWbyUD73bKZJ3bGi?filename=style.css">
49-
```
44+
::: tip
5045

51-
```
52-
<link rel="stylesheet" href="/ipfs/QmNrgEMcUygbKzZeZgYFosdd27VE9KnWbyUD73bKZJ3bGi?filename=style.css">
53-
```
46+
An example of user agent that support IPFS natively is [Brave](https://brave.com/ipfs-support/) or a regular web browser with [IPFS Companion](https://docs.ipfs.tech/install/ipfs-companion/) extension installed next to IPFS node such as [IPFS Desktop](https://docs.ipfs.tech/install/ipfs-desktop/).
5447

55-
User agents that support IPFS, such as a browser with [ipfs-companion](https://docs.ipfs.tech/install/ipfs-companion/), may recognize the `/ipfs/<CID>` content path and load the related asset over IPFS instead of HTTP. User agents without IPFS support still get the correct data from the original HTTP server.
5648
:::
5749

5850
## Path gateway
@@ -78,10 +70,10 @@ https://ipfs.io/ipfs/QmT5NvUtoM5nWFfrQdVrFtvGfKFmG7AHE8P34isapyhCxX/wiki/Mars.ht
7870
```
7971

8072
### Using IPNS
81-
Given an IPNS `<ipnsid>`, a URL path can be constructed as follows:
73+
Given an [IPNS Name](https://specs.ipfs.tech/ipns/ipns-record/#ipns-name) `<ipns-name>`, a URL path can be constructed as follows:
8274

8375
```plaintext
84-
https://<gateway-host>.tld/ipns/<ipnsid>/path/to/resource
76+
https://<gateway-host>.tld/ipns/<ipns-name>/path/to/resource
8577
```
8678

8779
Example:
@@ -91,7 +83,7 @@ https://ipfs.io/ipns/k51qzi5uqu5dlvj2baxnqndepeb86cbk3ng7n3i46uzyxzyqj2xjonzllnv
9183
```
9284

9385
### Using DNSLink
94-
Given a DNSLink `<dnslink>`, a URL path can be constructed as follows:
86+
Given a `<dnslink>` (DNS name with [DNSLink](https://dnslink.dev/) TXT record), a URL path can be constructed as follows:
9587

9688
```plaintext
9789
https://<gateway-host>.tld/ipns/<dnslink>/path/to/resource
@@ -125,7 +117,7 @@ https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.cf-ipfs
125117
https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.localhost:8080/wiki/
126118
```
127119

128-
#### Native support in Kubo 0.5+
120+
#### Native support in Kubo
129121

130122
[Kubo](https://dist.ipfs.tech/#kubo) provides native support for subdomain gateways on hostnames defined in the [`Gateway.PublicGateways`](https://github.com/ipfs/kubo/blob/master/docs/config.md#gatewaypublicgateways) configuration map.
131123

0 commit comments

Comments
 (0)