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 <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Josh Wong 2024-06-25 06:42:03 +08:00 committed by GitHub
parent 530f8a0b05
commit 7289c4b036
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---
feat:Add credentials: include and Cookie header to prevent 401 error

View File

@ -67,9 +67,16 @@ export class Client {
}
stream(url: URL): EventSource {
const headers = new Headers();
if (this && this.cookies) {
headers.append("Cookie", this.cookies);
}
this.abort_controller = new AbortController();
this.stream_instance = readable_stream(url.toString(), {
credentials: "include",
headers: headers,
signal: this.abort_controller.signal
});