perf: Assistant dynamic certificate

This commit is contained in:
fit2cloud-chenyw
2025-07-28 15:03:54 +08:00
parent a2ddda40d4
commit 38f46411fb
4 changed files with 56 additions and 3 deletions
+2 -1
View File
@@ -245,7 +245,7 @@ class HttpService {
return this.request({ ...config, method: 'POST', url, data })
}
public fetchStream(url: string, data?: any, controller?: AbortController): Promise<any> {
public async fetchStream(url: string, data?: any, controller?: AbortController): Promise<any> {
const token = wsCache.get('user.token')
const heads: any = {
'Content-Type': 'application/json',
@@ -257,6 +257,7 @@ class HttpService {
heads['X-SQLBOT-ASSISTANT-TOKEN'] = `Assistant ${assistantStore.getToken}`
if (heads['X-SQLBOT-TOKEN']) delete heads['X-SQLBOT-TOKEN']
if (assistantStore.getType && assistantStore.getCertificate) {
await assistantStore.refreshCertificate()
heads['X-SQLBOT-ASSISTANT-CERTIFICATE'] = btoa(
encodeURIComponent(assistantStore.getCertificate)
)