requestTransform
constrequestTransform: (config?) =>Policy
Defined in: src/policies/transform/transform.ts:53
Modify request headers before they reach the upstream service.
Applies header transformations in order: rename → set → remove. Handles
Cloudflare Workers’ immutable Request.headers by cloning the request
with modified headers.
Parameters
Section titled “Parameters”config?
Section titled “config?”Header set/remove/rename operations. At least one should be provided.
Returns
Section titled “Returns”A Policy at priority 50 (mid-pipeline, after auth, before upstream).
Example
Section titled “Example”import { requestTransform } from "@homegrower-club/stoma/policies";
// Add API version header and strip cookiesrequestTransform({ setHeaders: { "x-api-version": "2024-01-01" }, removeHeaders: ["cookie"],});
// Rename a legacy header to the new conventionrequestTransform({ renameHeaders: { "x-old-auth": "authorization" },});