| title | Detecting User-Preferred IPFS Gateway | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| description | Specification of the rules and standards for detecting and identifying user-preferred IPFS gateways within applications, enabling seamless integration and user control. | ||||||||||||||||||
| date | 2025-12-16 | ||||||||||||||||||
| maturity | reliable | ||||||||||||||||||
| editors |
|
||||||||||||||||||
| tags |
|
||||||||||||||||||
| order | 99 |
This document defines conventions for how applications can identify available IPFS gateway, and how IPFS gateway implementations can signal own endpoint to client applications.
There are two ways of hinting user-preferred gateway URL:
- Setting the
IPFS_GATEWAYenvironment variable - Creating a
gatewayfile at a well-known path
Applications SHOULD evaluate these hints in order and stop on the first match:
- Check if a valid
IPFS_GATEWAYenvironment variable is set - Check if a valid
gatewayfile is present at one of well-known filesystem paths
When IPFS_GATEWAY environment variable is set, the value SHOULD be interpreted
as URL of IPFS Gateway application to use.
This variable SHOULD override gateway selection done by all other means, including internal application configuration.
Client application SHOULD check if file is present at specific filesystem paths, in order:
- If
IPFS_PATHis set, try$IPFS_PATH/gateway - If
HOMEis set, try$HOME/.ipfs/gateway - Try OS-specific paths:
- Linux/Unix:
$XDG_CONFIG_HOME/ipfs/gateway(only ifXDG_CONFIG_HOMEis set)$HOME/.config/ipfs/gateway(default XDG location)/etc/ipfs/gateway(system-wide)
- Windows:
%LOCALAPPDATA%/ipfs/gateway(local user)%APPDATA%/ipfs/gateway(roaming user)%PROGRAMDATA%/ipfs/gateway(system-wide)
- macOS:
$HOME/Library/Application Support/ipfs/gateway(user)/Library/Application Support/ipfs/gateway(system-wide)
- Linux/Unix:
When gateway file is present, the file contents MUST be interpreted as an
ASCII text file with one URL per line (separated by \n or \r\n).
The first line MUST be a valid http:// or https:// URL without a path
(e.g., http://127.0.0.1:8080). The gateway at this URL MUST support
:cite[trustless-gateway], SHOULD support :cite[path-gateway] when deserialized
responses are required, and SHOULD support :cite[subdomain-gateway] when Origin
isolation is required.
Implementations MAY support additional lines for gateway pools or failover. Implementations that do not support multiple URLs SHOULD read only the first line and ignore the rest of the file.
Applications that integrate IPFS support via HTTP gateway:
MUST NOT hard-code non-localhost URL as a default fallback. Instead, SHOULD ask user to define preferred IPFS gateway using one of methods defined in this document.
SHOULD either warn user when non-localhost gateway is used for deserialized responses (warning about the risk of MITM), or (preferred) limit HTTP use outside of localhost to verifiable response types defined in :cite[trustless-gateway].
Applications SHOULD never default to public gateways. Instead, suggest to the user how to run a local node.
Implementers SHOULD test against implementations mentioned in :cite[ipip-0280] as the baseline for making decisions around maximizing interoperability.
Copyright and related rights waived via CC0.