Skip to content

Commit 1b7282a

Browse files
authored
fix(streaming): use CSRF-token if presented (#2781)
1 parent 75a950b commit 1b7282a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/services/api/streaming.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export interface StreamQueryOptions {
2828
}
2929

3030
export class StreamingAPI extends BaseYdbAPI {
31+
private csrfToken?: string;
32+
33+
setCSRFToken = (token: string) => {
34+
this.csrfToken = token;
35+
};
36+
3137
async streamQuery<Action extends Actions>(
3238
params: StreamQueryParams<Action>,
3339
options: StreamQueryOptions,
@@ -48,6 +54,10 @@ export class StreamingAPI extends BaseYdbAPI {
4854
'Content-Type': 'application/json',
4955
});
5056

57+
if (this.csrfToken) {
58+
headers.set('X-CSRF-Token', this.csrfToken);
59+
}
60+
5161
if (params.tracingLevel) {
5262
headers.set('X-Trace-Verbosity', String(params.tracingLevel));
5363
}

0 commit comments

Comments
 (0)