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 0746d95
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

Check warning on line 113 in packages/network/src/fetch.ts

View check run for this annotation

Codecov / codecov/patch

packages/network/src/fetch.ts#L113

Added line #L113 was not covered by tests
: (context.init.headers = new Headers(context.init.headers));
headers.set(httpHeader, apiKey);
context.init.headers = headers;
},
};
}
Expand Down

0 comments on commit 0746d95

Please sign in to comment.