Bravesite is an open-source Cloudflare Worker that acts as a seamless bridge between Web2 and Web3, enabling any browser to access content associated with Unstoppable Domains .brave addresses—simply by appending .site to the .brave domain.
Example:
If you own sunspot.brave, you can serve your IPFS-hosted site at https://sunspot.brave.site—no browser plugins, no special gateways, no extra setup.
-
DNS Mapping:
When a user visitshttps://<domain-or-subdomain>.brave.site, the Worker extracts<domain-or-subdomain>and constructs the corresponding Unstoppable Domain:<domain-or-subdomain>.brave. -
Unstoppable Domains API:
The Worker queries the Unstoppable Domains API to resolve the domain. It first checks for abrowser.redirect_urlrecord. -
Redirect Handling (New): If a
browser.redirect_urlis found in the domain's records, the Worker immediately issues an HTTP 302 redirect to that URL. This takes precedence over IPFS content. -
IPFS Content Fetching:
If no redirect URL is found, the Worker fetches the associated IPFS content hash (from records likedweb.ipfs.hash,ipfs.html.value, orcrypto.IPFS.value). -
IPFS Content Delivery:
The Worker attempts to fetch the content from multiple public IPFS gateways (Cloudflare, ipfs.io, dweb.link) concurrently, using the first successful response. A fallback to sequential retries is in place for resilience. -
Content Serving:
The fetched IPFS content is served directly to the browser with appropriate content-type headers, CORS, and caching.
- Web2/Web3 Bridge:
Access decentralized IPFS content or Web2 redirect URLs from any browser using familiar URLs. - Redirect URL Support:
If a
.bravedomain has abrowser.redirect_urlrecord, users will be seamlessly redirected, allowing for easy pointing to existing Web2 sites. - Subdomain and Base Domain Support:
Resolves both
yourdomain.brave.site(toyourdomain.brave) andsub.yourdomain.brave.site(tosub.yourdomain.brave). - Optimized IPFS Fetching:
UsesPromise.racefor faster IPFS gateway responses, with fallback to sequential retries. - API Response Caching: Caches responses from the Unstoppable Domains API to improve performance for repeated requests.
- Multi-Gateway Resilience:
Tries several IPFS gateways and retries on failure for robust content delivery. - No Plugins Required:
Works out-of-the-box in any browser—no extensions or wallet required. - Open Source & Extensible:
Apache 2.0 licensed. Easily adapt for other TLDs or decentralized protocols.
.
├── worker.js # Main Cloudflare Worker logic (Web2/Web3 bridge)
├── wrangler.jsonc # Cloudflare Worker configuration
├── package.json # Project scripts and dependencies
├── LICENSE # Apache 2.0 License
├── src/
│ └── index.ts # Example starter worker (not used in main logic)
├── test/
│ └── index.spec.ts # Example tests (not for main worker.js)
└── ... # Other config and support files
-
Entry Point:
The Worker listens for all fetch events and processes requests to*.brave.site. -
Subdomain Extraction:
Parses the subdomain from the request (e.g.,sunspotfromsunspot.brave.site). -
Unstoppable Domains Lookup:
Uses the Unstoppable Domains API (requires an API key) to resolve the.bravedomain and extract the IPFS hash. -
IPFS Fetching:
Attempts to fetch the content from multiple gateways, with retries and error handling. -
Content-Type Detection:
Sets the correctContent-Typeheader based on the file extension or gateway response. -
CORS & Caching:
AddsAccess-Control-Allow-Origin: *andCache-Control: public, max-age=3600for broad compatibility and performance.
- Node.js (v18+ recommended)
- Cloudflare Wrangler CLI
git clone https://github.com/yourusername/bravesite.git
cd bravesitenpm install- Copy your Unstoppable Domains API key.
- Set it as a secret in your Cloudflare Worker environment:
npx wrangler secret put UNSTOPPABLE_API_KEYStart a local development server:
npm run devVisit http://localhost:8787 and test with a custom hosts entry if needed.
npm run deploy- Register a
.bravedomain via Unstoppable Domains. - Set your IPFS hash in the domain records (e.g.,
dweb.ipfs.hash) OR set a redirect URL in thebrowser.redirect_urlrecord. - Access your decentralized site or redirect at:
https://<yourdomain>.brave.site
or for subdomains:
https://<subdomain>.<yourdomain>.brave.site
Example (IPFS):
If you own sunspot.brave and set its IPFS hash, visit:
https://sunspot.brave.site
Example (Redirect):
If you own mysite.brave and set browser.redirect_url to https://myothersite.com, visiting https://mysite.brave.site will redirect to https://myothersite.com.
-
wrangler.jsonc
Main configuration for Cloudflare deployment.
Example:{ "name": "bravesite", "main": "worker.js", "account_id": "<your-cloudflare-account-id>", "compatibility_date": "2025-05-21" } -
Environment Variable:
UNSTOPPABLE_API_KEY: Your Unstoppable Domains API key (set as a secret).
- Add More Gateways:
Edit thegatewaysarray inworker.jsto add more IPFS gateways. - Support More TLDs:
Adjust the domain parsing logic to support other Unstoppable TLDs.
This project is licensed under the Apache 2.0 License.
Pull requests and issues are welcome! Please open an issue to discuss major changes.
Bravesite makes decentralized web content accessible to everyone, everywhere.