mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Allow settings custom headers in js client (#9930)
* Allow settings custom headers in js client * add changeset * get_jwt doesn't need additional headers * format --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
This commit is contained in:
parent
75ad3e3419
commit
eae345e5fd
6
.changeset/smart-houses-deny.md
Normal file
6
.changeset/smart-houses-deny.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/client": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Allow settings custom headers in js client
|
@ -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 });
|
||||
}
|
||||
@ -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();
|
||||
|
||||
|
@ -299,6 +299,7 @@ export interface ClientOptions {
|
||||
auth?: [string, string] | null;
|
||||
with_null_state?: boolean;
|
||||
events?: EventType[];
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface FileData {
|
||||
|
Loading…
x
Reference in New Issue
Block a user