Skip to content

Commit

Permalink
Add credentials: include and Cookie header to prevent 401 error (#8600)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
yinkiu602 and gradio-pr-bot authored Jun 24, 2024
1 parent 530f8a0 commit 7289c4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/flat-results-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---

feat:Add credentials: include and Cookie header to prevent 401 error
7 changes: 7 additions & 0 deletions client/js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down

0 comments on commit 7289c4b

Please sign in to comment.