Skip to content

Commit

Permalink
fix: pass empty object to headers initializer to prevent crash on chr…
Browse files Browse the repository at this point in the history
…ome 49 (#235)
  • Loading branch information
IlyaSemenov authored Jun 6, 2023
1 parent fd2cded commit 5c24342
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export function createFetch(globalOptions: CreateFetchOptions): $Fetch {

// Set Content-Type and Accept headers to application/json by default
// for JSON serializable request bodies.
context.options.headers = new Headers(context.options.headers);
// Pass empty object as older browsers don't support undefined.
context.options.headers = new Headers(context.options.headers || {});
if (!context.options.headers.has("content-type")) {
context.options.headers.set("content-type", "application/json");
}
Expand Down

0 comments on commit 5c24342

Please sign in to comment.