Integrate Workers

Use Cloudflare Workers to add your own logic to HTTP traffic that passes through Gateway. A Gateway HTTP policy with the Forward action sends matching, permitted traffic to a Worker in your account. The Worker can modify a request, transform a response, return its own response, or start background work such as a notification or an R2 write. You can write your own Worker for your use case or adapt a Worker template.

Gateway handles the proxy connection, TLS decryption, and upstream routing. Your Worker receives standard Request and Response objects and Gateway context about the connection, policy, and user.

Gateway evaluates HTTP request policies before Forward policies. Body policies and inspection run after Worker invocation and can interrupt the Worker if they block the request.

A Forward policy does not override a Block policy or replace Gateway inspection. Refer to How Forward works for the request and response inspection order.

WebSocket traffic connects directly to the original upstream service and bypasses the Worker. Refer to Known limitations for protocol restrictions and other constraints.

The gateway-workers skill provides guidance for coding agents building or reviewing Workers used in Forward policies.


版本号 #3
由 壳壳虫 创建于 2026-11-01 01:24:24 UTC
由 cocobook-sync 更新于 2026-11-04 17:43:34 UTC