Example for customizing fetch requests with custom headers using Trustless Gateway Block Broker
- Node.js version 22 or higher
- Clone this repository
- Run
npm install - Run
node test.js
This example shows how to use Helia's Trustless Gateway Block Broker to customize HTTP requests to IPFS gateways. Specifically, it demonstrates:
- Adding custom headers (like User-Agent) to gateway requests
- Using the
transformRequestInitfunction to modify fetch parameters - Fetching content from IPFS using the customized gateway configuration
When you run the test, you should see:
- Helia initialization
- Custom headers being applied during block fetching
- Successful content retrieval from IPFS
- Content details (length and preview)
This is a standalone test repository to verify the example code that will be included in the official Helia documentation.