Repository navigation
Conversation
A Networking page explains the two networks a Pod can boot on and how they differ. The reference covers createEdgeNetwork, createFetchNetwork, opinionatedFetch, and boot's optional apiKey and new network option. Add the changelog for version 3.5.0.
Deploying labs-browserpod-previews with
|
| Latest commit: |
f12e7de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cabf1206.labs-browserpod-previews.pages.dev |
| Branch Preview URL: | https://browserpod-networks.labs-browserpod-previews.pages.dev |
Deploying labs-cheerpj-previews with
|
| Latest commit: |
f12e7de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8494d69e.labs-cheerpj-previews.pages.dev |
| Branch Preview URL: | https://browserpod-networks.labs-cheerpj-previews.pages.dev |
There was a problem hiding this comment.
Hi Yuri, thanks for your PR :)
A couple of things besides the comments left in the code:
BP_LATESTinpackages/astro-theme/replace-variables.tsis still 3.4.0. Should this be updated too?
Some Nits:
- The methods in the reference folder are alphabetical after
boot, but the new files are numbered 09–11 so they appear after run in the sidebar. Worth renumbering to keep the order? - Those same two “custom handler” examples create network but never boot a Pod, unlike every other example on the pages. Minor, but nice to have for consistency.
|
|
||
| ## Options | ||
|
|
||
| - **fetch (`function`, _optional_)** - A custom fetch function to handle outgoing requests. Defaults to the browser's global [`fetch`]. The custom handler receives the browser's default implementation as `init.defaultFetch`, allowing you to inspect, modify, or proxy requests. |
There was a problem hiding this comment.
| - **fetch (`function`, _optional_)** - A custom fetch function to handle outgoing requests. Defaults to the browser's global [`fetch`]. The custom handler receives the browser's default implementation as `init.defaultFetch`, allowing you to inspect, modify, or proxy requests. | |
| - **fetch (`function`, _optional_)** - A custom fetch function to handle outgoing requests. Defaults to the browser's global [`fetch()`][fetch]. The custom handler receives the browser's default implementation as `init.defaultFetch`, allowing you to inspect, modify, or proxy requests. |
| Pods can also boot without an API key on a **fetch network**, which routes network requests directly through your browser using `fetch()`. An API key is only required when booting on an **edge network**, which enables [Portals](/docs/understanding-browserpod/portals) and allows connections to external services without browser CORS restrictions. See [Networking](/docs/understanding-browserpod/networking) for details. | ||
|
|
There was a problem hiding this comment.
The FAQ page still answers “Do I need an API key?” with a flat “Yes” (14-more/01-FAQ.md:16). The same for 01-quickstart.md:10
Could we update it in this PR so it doesn’t contradict the new Networking page?
| ```js | ||
| // Edge network: pass an API key | ||
| const pod = await BrowserPod.boot({ apiKey: "your_key_here" }); | ||
|
|
||
| // Fetch network: omit the API key | ||
| const pod = await BrowserPod.boot({}); | ||
| ``` |
There was a problem hiding this comment.
These two lines are in one block, so copy-pasting it fails with “Identifier ‘pod’ has already been declared”. Could we split them into two code blocks?
| | ----------------------------------------------------- | --------------------------------- | --------------------------- | | ||
| | **API key** | Required | Not required | | ||
| | **Token cost** | 10 tokens per boot | Free (0 tokens) | | ||
| | **Outgoing HTTP, HTTPS, WebSockets** | To any domain allowed by your key | To origins that permit CORS | |
There was a problem hiding this comment.
I am a bit confused here. Just trying to understand this correctly:
This row lists WebSockets for both networks, but createFetchNetwork describes it as HTTP/HTTPS only, and fetch() can’t open a WebSocket. Should the fetch column here say “Not supported” for WebSockets, or split the row? Please correct me if I am wrong.
There was a problem hiding this comment.
yes it's confusing as written. I propose to just remove this table, but we also need to explain somewhere that websockets do work.
How:
the fetch() implementation that the user provides can return something like:
return new Response(null, {
status: 101,
webSocket,
});This is the same API of cloudflare workers, so maybe we can point to that: https://developers.cloudflare.com/workers/examples/websockets/
it's also an advanced feature since our default fetch will do this automatically
|
|
||
| A [Pod](/docs/reference/BrowserPod) connects to the internet using one of two network types: | ||
|
|
||
| - **Edge network:** Routes network traffic through BrowserPod's edge proxy servers. This requires an [API key](/docs/understanding-browserpod/api-key) and deducts tokens, but allows outgoing connections to any domain allowed by your key and enables public access to servers via [Portals](/docs/understanding-browserpod/portals). |
There was a problem hiding this comment.
| - **Edge network:** Routes network traffic through BrowserPod's edge proxy servers. This requires an [API key](/docs/understanding-browserpod/api-key) and deducts tokens, but allows outgoing connections to any domain allowed by your key and enables public access to servers via [Portals](/docs/understanding-browserpod/portals). | |
| - **Edge network:** Routes network traffic through BrowserPod's edge proxy servers. This requires an [API key](/docs/understanding-browserpod/api-key) and deducts tokens, but allows outgoing connections to any domain permitted by your key and enables public access to servers via [Portals](/docs/understanding-browserpod/portals). |
| const pod = await BrowserPod.boot({ network }); | ||
| ``` | ||
|
|
||
| ## Custom fetch handler |
There was a problem hiding this comment.
| ## Custom fetch handler | |
| ### Custom fetch handler |
|
BP_LATEST should be updated to 3.5.0 yes! |
A Networking page explains the two networks a Pod can boot on and how they
differ. The reference covers createEdgeNetwork, createFetchNetwork,
opinionatedFetch, and boot's optional apiKey and new network option.
Add the changelog for version 3.5.0.