TunnelRead
Source:
src/Cloudflare/Tunnel/TunnelRead.ts
Binding that lets a Worker read Cloudflare Tunnels at runtime.
Creates a scoped {@link AccountApiToken} with only the Cloudflare Tunnel Read permission and binds its outputs into the Worker (the token value as a
secret_text binding) so runtime code can authenticate.
Reading tunnels at runtime
Section titled “Reading tunnels at runtime”Bind the read client
Bind once in the Init phase; every method is available on the returned client.
const tunnels = yield* Cloudflare.TunnelRead.bind();List tunnels
const { result } = yield* tunnels.list({ isDeleted: false });Fetch a tunnel and its connector token
getToken returns the plaintext token used to run cloudflared.
const tunnel = yield* tunnels.get(tunnelId);const token = yield* tunnels.getToken(tunnelId);Read the ingress configuration
const { config } = yield* tunnels.getConfiguration(tunnelId);Runtime Layer
Section titled “Runtime Layer”Provide {@link TunnelReadLive} in the Worker’s runtime layer.
Effect.provide(Cloudflare.TunnelReadLive)