この紹介文は現在英語版のみです。
Overview
@cloudflare/containers is the official class for interacting with Containers on Cloudflare Workers. It extends a container-enabled Durable Object with container-specific functionality.
Features
- HTTP request proxying and WebSocket forwarding
- Outbound request interception by host or with a catch-all handler, including HTTPS
- Host allow/deny lists with glob patterns
- Simple lifecycle management — start and stop containers
- Event hooks:
onStart,onStopandonError - A configurable sleep timeout that renews on each request
- Load-balancing helpers such as
getRandom
Installation
npm install @cloudflare/containers
Extend the Container class, set a defaultPort, and route requests to an instance with getContainer.