Skip to content

Commit 26bac8a

Browse files
committed
use cf types
1 parent c8111a7 commit 26bac8a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/service-utils/src/cf-worker/usageV2.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Request } from "@cloudflare/workers-types";
1+
import { Headers, type Request, fetch } from "@cloudflare/workers-types";
22
import type { CoreAuthInput } from "src/core/types.js";
33
import type {
44
ClientUsageV2Event,
@@ -32,14 +32,12 @@ export async function sendUsageV2Events<T extends UsageV2Options>(
3232
// Forward headers from the origin request.
3333
// Determine endpoint and auth header based on provided credentials.
3434
let url: string;
35-
const headers: HeadersInit = {
36-
...authInput.req.headers,
37-
"Content-Type": "application/json",
38-
};
35+
const headers = new Headers(authInput.req.headers);
36+
headers.set("Content-Type", "application/json");
3937
if (serviceKey) {
4038
// If a service key is provided, call the non-public usage endpoint.
4139
url = `${usageBaseUrl}/usage-v2/${source}`;
42-
headers["x-service-api-key"] = serviceKey;
40+
headers.set("x-service-api-key", serviceKey);
4341
} else {
4442
url = `${usageBaseUrl}/usage-v2/${source}/client`;
4543
}

0 commit comments

Comments
 (0)