Skip to content

Commit

Permalink
Convert to Uint8Array to avoid Content-Type override (langchain-ai#1222)
Browse files Browse the repository at this point in the history
* Convert to Uint8Array to avoid Content-Type override

* Fix prettier
  • Loading branch information
dqbd authored May 11, 2023
1 parent ace3ee7 commit cae013b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions langchain/src/util/axios-fetch-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ function createRequest(config) {
headers.delete("Content-Type");
}
}
// Some `fetch` implementations will override the Content-Type to text/plain
// when body is a string.
// See https://github.com/hwchase17/langchainjs/issues/1010
if (typeof options.body === "string") {
options.body = new TextEncoder().encode(options.body);
}
if (config.mode) {
options.mode = config.mode;
}
Expand Down

0 comments on commit cae013b

Please sign in to comment.