Skip to content

Commit 3c19b93

Browse files
committed
fix: allow read-only headers in fetch
1 parent 525c3ff commit 3c19b93

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/network/src/fetch.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ export function createApiKeyMiddleware({
108108
const reqUrl = new URL(context.url);
109109
if (!hostMatches(reqUrl.host, host)) return; // Skip middleware if host does not match pattern
110110

111-
const headers = new Headers(context.init.headers);
111+
const headers =
112+
context.init.headers instanceof Headers
113+
? context.init.headers
114+
: (context.init.headers = new Headers(context.init.headers));
112115
headers.set(httpHeader, apiKey);
113-
context.init.headers = headers;
114116
},
115117
};
116118
}

0 commit comments

Comments
 (0)