remove DEFAULT_API_HOST
This commit is contained in:
parent
5141145e4d
commit
a50c282d01
|
@ -23,6 +23,7 @@ import {
|
||||||
import { prettyObject } from "@/app/utils/format";
|
import { prettyObject } from "@/app/utils/format";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { getMessageTextContent } from "@/app/utils";
|
import { getMessageTextContent } from "@/app/utils";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export interface OpenAIListModelResponse {
|
export interface OpenAIListModelResponse {
|
||||||
object: string;
|
object: string;
|
||||||
|
@ -178,6 +179,7 @@ export class QwenApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
ChatMessageTool,
|
ChatMessageTool,
|
||||||
} from "@/app/store";
|
} from "@/app/store";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { DEFAULT_API_HOST } from "@/app/constant";
|
import { ANTHROPIC_BASE_URL } from "@/app/constant";
|
||||||
import { getMessageTextContent, isVisionModel } from "@/app/utils";
|
import { getMessageTextContent, isVisionModel } from "@/app/utils";
|
||||||
import { preProcessImageContent, stream } from "@/app/utils/chat";
|
import { preProcessImageContent, stream } from "@/app/utils/chat";
|
||||||
import { cloudflareAIGatewayUrl } from "@/app/utils/cloudflare";
|
import { cloudflareAIGatewayUrl } from "@/app/utils/cloudflare";
|
||||||
|
@ -388,9 +388,7 @@ export class ClaudeApi implements LLMApi {
|
||||||
if (baseUrl.trim().length === 0) {
|
if (baseUrl.trim().length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
|
|
||||||
baseUrl = isApp
|
baseUrl = isApp ? ANTHROPIC_BASE_URL : ApiPath.Anthropic;
|
||||||
? DEFAULT_API_HOST + "/api/proxy/anthropic"
|
|
||||||
: ApiPath.Anthropic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!baseUrl.startsWith("http") && !baseUrl.startsWith("/api")) {
|
if (!baseUrl.startsWith("http") && !baseUrl.startsWith("/api")) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
import { prettyObject } from "@/app/utils/format";
|
import { prettyObject } from "@/app/utils/format";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { getMessageTextContent } from "@/app/utils";
|
import { getMessageTextContent } from "@/app/utils";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export interface OpenAIListModelResponse {
|
export interface OpenAIListModelResponse {
|
||||||
object: string;
|
object: string;
|
||||||
|
@ -197,6 +198,7 @@ export class ErnieApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {
|
||||||
import { prettyObject } from "@/app/utils/format";
|
import { prettyObject } from "@/app/utils/format";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { getMessageTextContent } from "@/app/utils";
|
import { getMessageTextContent } from "@/app/utils";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export interface OpenAIListModelResponse {
|
export interface OpenAIListModelResponse {
|
||||||
object: string;
|
object: string;
|
||||||
|
@ -165,6 +166,7 @@ export class DoubaoApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from "../api";
|
} from "../api";
|
||||||
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { DEFAULT_API_HOST } from "@/app/constant";
|
import { GEMINI_BASE_URL } from "@/app/constant";
|
||||||
import Locale from "../../locales";
|
import Locale from "../../locales";
|
||||||
import {
|
import {
|
||||||
EventStreamContentType,
|
EventStreamContentType,
|
||||||
|
@ -22,6 +22,7 @@ import {
|
||||||
isVisionModel,
|
isVisionModel,
|
||||||
} from "@/app/utils";
|
} from "@/app/utils";
|
||||||
import { preProcessImageContent } from "@/app/utils/chat";
|
import { preProcessImageContent } from "@/app/utils/chat";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export class GeminiProApi implements LLMApi {
|
export class GeminiProApi implements LLMApi {
|
||||||
path(path: string): string {
|
path(path: string): string {
|
||||||
|
@ -34,7 +35,7 @@ export class GeminiProApi implements LLMApi {
|
||||||
|
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
baseUrl = isApp ? DEFAULT_API_HOST + `/api/proxy/google` : ApiPath.Google;
|
baseUrl = isApp ? GEMINI_BASE_URL : ApiPath.Google;
|
||||||
}
|
}
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
||||||
|
@ -213,6 +214,7 @@ export class GeminiProApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
ApiPath,
|
||||||
DEFAULT_API_HOST,
|
IFLYTEK_BASE_URL,
|
||||||
Iflytek,
|
Iflytek,
|
||||||
REQUEST_TIMEOUT_MS,
|
REQUEST_TIMEOUT_MS,
|
||||||
} from "@/app/constant";
|
} from "@/app/constant";
|
||||||
|
@ -22,6 +22,7 @@ import {
|
||||||
import { prettyObject } from "@/app/utils/format";
|
import { prettyObject } from "@/app/utils/format";
|
||||||
import { getClientConfig } from "@/app/config/client";
|
import { getClientConfig } from "@/app/config/client";
|
||||||
import { getMessageTextContent } from "@/app/utils";
|
import { getMessageTextContent } from "@/app/utils";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
import { RequestPayload } from "./openai";
|
import { RequestPayload } from "./openai";
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ export class SparkApi implements LLMApi {
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const apiPath = ApiPath.Iflytek;
|
const apiPath = ApiPath.Iflytek;
|
||||||
baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath;
|
baseUrl = isApp ? IFLYTEK_BASE_URL + apiPath : apiPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
|
@ -149,6 +150,7 @@ export class SparkApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// azure and openai, using same models. so using same LLMApi.
|
// azure and openai, using same models. so using same LLMApi.
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
ApiPath,
|
||||||
DEFAULT_API_HOST,
|
MOONSHOT_BASE_URL,
|
||||||
Moonshot,
|
Moonshot,
|
||||||
REQUEST_TIMEOUT_MS,
|
REQUEST_TIMEOUT_MS,
|
||||||
} from "@/app/constant";
|
} from "@/app/constant";
|
||||||
|
@ -40,7 +40,7 @@ export class MoonshotApi implements LLMApi {
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const apiPath = ApiPath.Moonshot;
|
const apiPath = ApiPath.Moonshot;
|
||||||
baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath;
|
baseUrl = isApp ? MOONSHOT_BASE_URL + apiPath : apiPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// azure and openai, using same models. so using same LLMApi.
|
// azure and openai, using same models. so using same LLMApi.
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
ApiPath,
|
||||||
DEFAULT_API_HOST,
|
OPENAI_BASE_URL,
|
||||||
DEFAULT_MODELS,
|
DEFAULT_MODELS,
|
||||||
OpenaiPath,
|
OpenaiPath,
|
||||||
Azure,
|
Azure,
|
||||||
|
@ -98,7 +98,7 @@ export class ChatGPTApi implements LLMApi {
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
|
const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
|
||||||
baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath;
|
baseUrl = isApp ? OPENAI_BASE_URL + apiPath : apiPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { ApiPath, DEFAULT_API_HOST, REQUEST_TIMEOUT_MS } from "@/app/constant";
|
import { ApiPath, TENCENT_BASE_URL, REQUEST_TIMEOUT_MS } from "@/app/constant";
|
||||||
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -22,6 +22,7 @@ import mapKeys from "lodash-es/mapKeys";
|
||||||
import mapValues from "lodash-es/mapValues";
|
import mapValues from "lodash-es/mapValues";
|
||||||
import isArray from "lodash-es/isArray";
|
import isArray from "lodash-es/isArray";
|
||||||
import isObject from "lodash-es/isObject";
|
import isObject from "lodash-es/isObject";
|
||||||
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export interface OpenAIListModelResponse {
|
export interface OpenAIListModelResponse {
|
||||||
object: string;
|
object: string;
|
||||||
|
@ -70,9 +71,7 @@ export class HunyuanApi implements LLMApi {
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
baseUrl = isApp
|
baseUrl = isApp ? TENCENT_BASE_URL : ApiPath.Tencent;
|
||||||
? DEFAULT_API_HOST + "/api/proxy/tencent"
|
|
||||||
: ApiPath.Tencent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
|
@ -179,6 +178,7 @@ export class HunyuanApi implements LLMApi {
|
||||||
controller.signal.onabort = finish;
|
controller.signal.onabort = finish;
|
||||||
|
|
||||||
fetchEventSource(chatPath, {
|
fetchEventSource(chatPath, {
|
||||||
|
fetch,
|
||||||
...chatPayload,
|
...chatPayload,
|
||||||
async onopen(res) {
|
async onopen(res) {
|
||||||
clearTimeout(requestTimeoutId);
|
clearTimeout(requestTimeoutId);
|
||||||
|
|
|
@ -11,7 +11,6 @@ export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
|
||||||
|
|
||||||
export const STABILITY_BASE_URL = "https://api.stability.ai";
|
export const STABILITY_BASE_URL = "https://api.stability.ai";
|
||||||
|
|
||||||
export const DEFAULT_API_HOST = "https://api.nextchat.dev";
|
|
||||||
export const OPENAI_BASE_URL = "https://api.openai.com";
|
export const OPENAI_BASE_URL = "https://api.openai.com";
|
||||||
export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
|
export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
import {
|
import {
|
||||||
ApiPath,
|
|
||||||
DEFAULT_API_HOST,
|
|
||||||
GoogleSafetySettingsThreshold,
|
GoogleSafetySettingsThreshold,
|
||||||
ServiceProvider,
|
ServiceProvider,
|
||||||
StoreKey,
|
StoreKey,
|
||||||
|
OPENAI_BASE_URL,
|
||||||
|
ANTHROPIC_BASE_URL,
|
||||||
|
GEMINI_BASE_URL,
|
||||||
|
BAIDU_BASE_URL,
|
||||||
|
BYTEDANCE_BASE_URL,
|
||||||
|
ALIBABA_BASE_URL,
|
||||||
|
TENCENT_BASE_URL,
|
||||||
|
MOONSHOT_BASE_URL,
|
||||||
|
STABILITY_BASE_URL,
|
||||||
|
IFLYTEK_BASE_URL,
|
||||||
} from "../constant";
|
} from "../constant";
|
||||||
import { getHeaders } from "../client/api";
|
import { getHeaders } from "../client/api";
|
||||||
import { getClientConfig } from "../config/client";
|
import { getClientConfig } from "../config/client";
|
||||||
|
@ -15,46 +23,6 @@ let fetchState = 0; // 0 not fetch, 1 fetching, 2 done
|
||||||
|
|
||||||
const isApp = getClientConfig()?.buildMode === "export";
|
const isApp = getClientConfig()?.buildMode === "export";
|
||||||
|
|
||||||
const DEFAULT_OPENAI_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/openai"
|
|
||||||
: ApiPath.OpenAI;
|
|
||||||
|
|
||||||
const DEFAULT_GOOGLE_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/google"
|
|
||||||
: ApiPath.Google;
|
|
||||||
|
|
||||||
const DEFAULT_ANTHROPIC_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/anthropic"
|
|
||||||
: ApiPath.Anthropic;
|
|
||||||
|
|
||||||
const DEFAULT_BAIDU_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/baidu"
|
|
||||||
: ApiPath.Baidu;
|
|
||||||
|
|
||||||
const DEFAULT_BYTEDANCE_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/bytedance"
|
|
||||||
: ApiPath.ByteDance;
|
|
||||||
|
|
||||||
const DEFAULT_ALIBABA_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/alibaba"
|
|
||||||
: ApiPath.Alibaba;
|
|
||||||
|
|
||||||
const DEFAULT_TENCENT_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/tencent"
|
|
||||||
: ApiPath.Tencent;
|
|
||||||
|
|
||||||
const DEFAULT_MOONSHOT_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/moonshot"
|
|
||||||
: ApiPath.Moonshot;
|
|
||||||
|
|
||||||
const DEFAULT_STABILITY_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/stability"
|
|
||||||
: ApiPath.Stability;
|
|
||||||
|
|
||||||
const DEFAULT_IFLYTEK_URL = isApp
|
|
||||||
? DEFAULT_API_HOST + "/api/proxy/iflytek"
|
|
||||||
: ApiPath.Iflytek;
|
|
||||||
|
|
||||||
const DEFAULT_ACCESS_STATE = {
|
const DEFAULT_ACCESS_STATE = {
|
||||||
accessCode: "",
|
accessCode: "",
|
||||||
useCustomConfig: false,
|
useCustomConfig: false,
|
||||||
|
@ -62,7 +30,7 @@ const DEFAULT_ACCESS_STATE = {
|
||||||
provider: ServiceProvider.OpenAI,
|
provider: ServiceProvider.OpenAI,
|
||||||
|
|
||||||
// openai
|
// openai
|
||||||
openaiUrl: DEFAULT_OPENAI_URL,
|
openaiUrl: OPENAI_BASE_URL,
|
||||||
openaiApiKey: "",
|
openaiApiKey: "",
|
||||||
|
|
||||||
// azure
|
// azure
|
||||||
|
@ -71,44 +39,44 @@ const DEFAULT_ACCESS_STATE = {
|
||||||
azureApiVersion: "2023-08-01-preview",
|
azureApiVersion: "2023-08-01-preview",
|
||||||
|
|
||||||
// google ai studio
|
// google ai studio
|
||||||
googleUrl: DEFAULT_GOOGLE_URL,
|
googleUrl: GEMINI_BASE_URL,
|
||||||
googleApiKey: "",
|
googleApiKey: "",
|
||||||
googleApiVersion: "v1",
|
googleApiVersion: "v1",
|
||||||
googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH,
|
googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH,
|
||||||
|
|
||||||
// anthropic
|
// anthropic
|
||||||
anthropicUrl: DEFAULT_ANTHROPIC_URL,
|
anthropicUrl: ANTHROPIC_BASE_URL,
|
||||||
anthropicApiKey: "",
|
anthropicApiKey: "",
|
||||||
anthropicApiVersion: "2023-06-01",
|
anthropicApiVersion: "2023-06-01",
|
||||||
|
|
||||||
// baidu
|
// baidu
|
||||||
baiduUrl: DEFAULT_BAIDU_URL,
|
baiduUrl: BAIDU_BASE_URL,
|
||||||
baiduApiKey: "",
|
baiduApiKey: "",
|
||||||
baiduSecretKey: "",
|
baiduSecretKey: "",
|
||||||
|
|
||||||
// bytedance
|
// bytedance
|
||||||
bytedanceUrl: DEFAULT_BYTEDANCE_URL,
|
bytedanceUrl: BYTEDANCE_BASE_URL,
|
||||||
bytedanceApiKey: "",
|
bytedanceApiKey: "",
|
||||||
|
|
||||||
// alibaba
|
// alibaba
|
||||||
alibabaUrl: DEFAULT_ALIBABA_URL,
|
alibabaUrl: ALIBABA_BASE_URL,
|
||||||
alibabaApiKey: "",
|
alibabaApiKey: "",
|
||||||
|
|
||||||
// moonshot
|
// moonshot
|
||||||
moonshotUrl: DEFAULT_MOONSHOT_URL,
|
moonshotUrl: MOONSHOT_BASE_URL,
|
||||||
moonshotApiKey: "",
|
moonshotApiKey: "",
|
||||||
|
|
||||||
//stability
|
//stability
|
||||||
stabilityUrl: DEFAULT_STABILITY_URL,
|
stabilityUrl: STABILITY_BASE_URL,
|
||||||
stabilityApiKey: "",
|
stabilityApiKey: "",
|
||||||
|
|
||||||
// tencent
|
// tencent
|
||||||
tencentUrl: DEFAULT_TENCENT_URL,
|
tencentUrl: TENCENT_BASE_URL,
|
||||||
tencentSecretKey: "",
|
tencentSecretKey: "",
|
||||||
tencentSecretId: "",
|
tencentSecretId: "",
|
||||||
|
|
||||||
// iflytek
|
// iflytek
|
||||||
iflytekUrl: DEFAULT_IFLYTEK_URL,
|
iflytekUrl: IFLYTEK_BASE_URL,
|
||||||
iflytekApiKey: "",
|
iflytekApiKey: "",
|
||||||
iflytekApiSecret: "",
|
iflytekApiSecret: "",
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import { downloadAs, readFromFile } from "../utils";
|
||||||
import { showToast } from "../components/ui-lib";
|
import { showToast } from "../components/ui-lib";
|
||||||
import Locale from "../locales";
|
import Locale from "../locales";
|
||||||
import { createSyncClient, ProviderType } from "../utils/cloud";
|
import { createSyncClient, ProviderType } from "../utils/cloud";
|
||||||
import { corsPath } from "../utils/cors";
|
|
||||||
|
|
||||||
export interface WebDavConfig {
|
export interface WebDavConfig {
|
||||||
server: string;
|
server: string;
|
||||||
|
@ -26,7 +25,7 @@ export type SyncStore = GetStoreState<typeof useSyncStore>;
|
||||||
const DEFAULT_SYNC_STATE = {
|
const DEFAULT_SYNC_STATE = {
|
||||||
provider: ProviderType.WebDAV,
|
provider: ProviderType.WebDAV,
|
||||||
useProxy: true,
|
useProxy: true,
|
||||||
proxyUrl: corsPath(ApiPath.Cors),
|
proxyUrl: ApiPath.Cors,
|
||||||
|
|
||||||
webdav: {
|
webdav: {
|
||||||
endpoint: "",
|
endpoint: "",
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { getClientConfig } from "../config/client";
|
|
||||||
import { DEFAULT_API_HOST } from "../constant";
|
|
||||||
|
|
||||||
export function corsPath(path: string) {
|
|
||||||
const baseUrl = getClientConfig()?.isApp ? `${DEFAULT_API_HOST}` : "";
|
|
||||||
|
|
||||||
if (baseUrl === "" && path === "") {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (!path.startsWith("/")) {
|
|
||||||
path = "/" + path;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path.endsWith("/")) {
|
|
||||||
path += "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${baseUrl}${path}`;
|
|
||||||
}
|
|
Loading…
Reference in New Issue