Skip to content

Commit 7289c4b

Browse files
Add credentials: include and Cookie header to prevent 401 error (#8600)
* Add credentials: include and Cookie header to prevent 401 error * FIx formatting * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 530f8a0 commit 7289c4b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/flat-results-divide.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/client": minor
3+
"gradio": minor
4+
---
5+
6+
feat:Add credentials: include and Cookie header to prevent 401 error

client/js/src/client.ts

+7
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ export class Client {
6767
}
6868

6969
stream(url: URL): EventSource {
70+
const headers = new Headers();
71+
if (this && this.cookies) {
72+
headers.append("Cookie", this.cookies);
73+
}
74+
7075
this.abort_controller = new AbortController();
7176

7277
this.stream_instance = readable_stream(url.toString(), {
78+
credentials: "include",
79+
headers: headers,
7380
signal: this.abort_controller.signal
7481
});
7582

0 commit comments

Comments
 (0)