From e60c0f009b49487307430145d305d5a471cbb39c Mon Sep 17 00:00:00 2001 From: Hk-Gosuto Date: Tue, 26 Dec 2023 12:41:39 +0800 Subject: [PATCH] fix: upload image error --- app/client/api.ts | 13 ++++++++----- app/client/platforms/utils.ts | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/client/api.ts b/app/client/api.ts index b5a72154c..3a8b3e68f 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -167,12 +167,15 @@ export class ClientApi { } } -export function getHeaders() { +export function getHeaders(ignoreHeaders?: boolean) { const accessStore = useAccessStore.getState(); - const headers: Record = { - "Content-Type": "application/json", - "x-requested-with": "XMLHttpRequest", - }; + let headers: Record = {}; + if (!ignoreHeaders) { + headers = { + "Content-Type": "application/json", + "x-requested-with": "XMLHttpRequest", + }; + } const modelConfig = useChatStore.getState().currentSession().mask.modelConfig; const isGoogle = modelConfig.model === "gemini-pro"; const isAzure = accessStore.provider === ServiceProvider.Azure; diff --git a/app/client/platforms/utils.ts b/app/client/platforms/utils.ts index a4127d0fe..6920dcc57 100644 --- a/app/client/platforms/utils.ts +++ b/app/client/platforms/utils.ts @@ -4,7 +4,7 @@ export class FileApi { async upload(file: any): Promise { const formData = new FormData(); formData.append("file", file); - var headers = getHeaders(); + var headers = getHeaders(true); var res = await fetch("/api/file/upload", { method: "POST", body: formData,