fix: upload image error

This commit is contained in:
Hk-Gosuto 2023-12-26 12:41:39 +08:00
parent 24de1bb77a
commit e60c0f009b
2 changed files with 9 additions and 6 deletions

View File

@ -167,12 +167,15 @@ export class ClientApi {
}
}
export function getHeaders() {
export function getHeaders(ignoreHeaders?: boolean) {
const accessStore = useAccessStore.getState();
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-requested-with": "XMLHttpRequest",
};
let headers: Record<string, string> = {};
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;

View File

@ -4,7 +4,7 @@ export class FileApi {
async upload(file: any): Promise<void> {
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,