From 915415b66d5b881cf025a3a9719d1f05164ea5c5 Mon Sep 17 00:00:00 2001 From: Phillip Ho Date: Tue, 4 Mar 2025 21:50:06 +0800 Subject: [PATCH] shallow copy headers without importing cf worker --- packages/service-utils/src/cf-worker/usageV2.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/service-utils/src/cf-worker/usageV2.ts b/packages/service-utils/src/cf-worker/usageV2.ts index 4063cde50c3..365806c79aa 100644 --- a/packages/service-utils/src/cf-worker/usageV2.ts +++ b/packages/service-utils/src/cf-worker/usageV2.ts @@ -1,3 +1,4 @@ +import type { Request } from "@cloudflare/workers-types"; import type { CoreAuthInput } from "../core/types.js"; import type { ClientUsageV2Event, @@ -33,7 +34,7 @@ export async function sendUsageV2Events( // Forward headers from the origin request. // Determine endpoint and auth header based on provided credentials. let url: string; - const headers = new Headers(authInput.req.headers); + const headers = new Headers(Object.fromEntries(authInput.req.headers)); headers.set("Content-Type", "application/json"); if (serviceKey) { // If a service key is provided, call the non-public usage endpoint.