Skip to content

Commit

Permalink
Merge branch 'main' into localstate
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs authored Nov 15, 2024
2 parents 63b62c0 + eae345e commit ec2e569
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/smart-houses-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/client": minor
"gradio": minor
---

feat:Allow settings custom headers in js client
10 changes: 10 additions & 0 deletions client/js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export class Client {
if (this && this.cookies) {
headers.append("Cookie", this.cookies);
}
if (this && this.options.headers) {
for (const name in this.options.headers) {
headers.append(name, this.options.headers[name]);
}
}

return fetch(input, { ...init, headers });
}
Expand All @@ -79,6 +84,11 @@ export class Client {
if (this && this.cookies) {
headers.append("Cookie", this.cookies);
}
if (this && this.options.headers) {
for (const name in this.options.headers) {
headers.append(name, this.options.headers[name]);
}
}

this.abort_controller = new AbortController();

Expand Down
1 change: 1 addition & 0 deletions client/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export interface ClientOptions {
auth?: [string, string] | null;
with_null_state?: boolean;
events?: EventType[];
headers?: Record<string, string>;
}

export interface FileData {
Expand Down

0 comments on commit ec2e569

Please sign in to comment.