Skip to content

Commit f2b041e

Browse files
authored
fix(ai): Use custom fetch if provided (#6787)
## Background Fixes a bug where `fetch` was not used and it always called the global `fetch`. This was introduced in #6746 ## Summary Call `this.fetch()` instead of `fetch()` ## Verification I verified in a patched package locally.
1 parent e862b5b commit f2b041e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎.changeset/mighty-rats-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
Fix custom `fetch` in HttpChatTransport

‎packages/ai/src/ui/http-chat-transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export abstract class HttpChatTransport<UI_MESSAGE extends UIMessage>
154154
};
155155
const credentials = preparedRequest?.credentials ?? this.credentials;
156156

157-
const response = await fetch(api, {
157+
const response = await this.fetch(api, {
158158
method: 'POST',
159159
headers: {
160160
'Content-Type': 'application/json',
@@ -197,7 +197,7 @@ export abstract class HttpChatTransport<UI_MESSAGE extends UIMessage>
197197
: { ...this.headers, ...options.headers };
198198
const credentials = preparedRequest?.credentials ?? this.credentials;
199199

200-
const response = await fetch(api, {
200+
const response = await this.fetch(api, {
201201
method: 'GET',
202202
headers,
203203
credentials,

0 commit comments

Comments
 (0)