proxy
proxy(
config?):Policy
Defined in: src/policies/proxy.ts:55
Apply additional header manipulation and timeout control to the upstream call.
Use this when you need per-route header injection, header stripping, or a custom timeout that wraps the upstream dispatch. The core proxy forwarding (URL, Service Binding, Handler) is handled by the gateway’s upstream handler — this policy layers on top of it.
preserveHost applies to URL upstreams, instructing the upstream handler
not to rewrite the Host header to the target host.
Handles Cloudflare Workers’ immutable Request.headers by cloning the
request when header modifications are needed.
Parameters
Section titled “Parameters”config?
Section titled “config?”ProxyPolicyConfig
Headers to add/strip, timeout, and host preservation. All fields optional.
Returns
Section titled “Returns”A Policy at priority 95 (runs late, just before the upstream call).
Example
Section titled “Example”import { proxy } from "@homegrower-club/stoma/policies";
// Add an internal auth header and strip cookies for the upstreamproxy({ headers: { "x-internal-key": "secret-123" }, stripHeaders: ["cookie", "x-forwarded-for"], timeout: 10_000,});
// Preserve the original Host header for virtual-host routingproxy({ preserveHost: true });