Skip to content

Commit

Permalink
fix: allow read-only headers in fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Oct 17, 2024
1 parent 525c3ff commit 3c19b93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/network/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ export function createApiKeyMiddleware({
const reqUrl = new URL(context.url);
if (!hostMatches(reqUrl.host, host)) return; // Skip middleware if host does not match pattern

const headers = new Headers(context.init.headers);
const headers =
context.init.headers instanceof Headers
? context.init.headers
: (context.init.headers = new Headers(context.init.headers));
headers.set(httpHeader, apiKey);
context.init.headers = headers;
},
};
}
Expand Down

0 comments on commit 3c19b93

Please sign in to comment.