diff --git a/src/shared/services/llm/adapters/qwen-adapter.ts b/src/shared/services/llm/adapters/qwen-adapter.ts index 6d3dc11..36a8fda 100644 --- a/src/shared/services/llm/adapters/qwen-adapter.ts +++ b/src/shared/services/llm/adapters/qwen-adapter.ts @@ -10,7 +10,11 @@ export class QwenAdapter extends BaseLLMAdapter { constructor(config: any) { super(config); - this.baseUrl = config.baseUrl || 'https://dashscope.aliyuncs.com/api/v1'; + if (import.meta.env.DEV) { + this.baseUrl = '/dashscope-proxy/api/v1'; + } else { + this.baseUrl = config.baseUrl || 'https://dashscope.aliyuncs.com/api/v1'; + } } async complete(request: LLMRequest): Promise { diff --git a/vite.config.ts b/vite.config.ts index c548f88..64b9943 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -51,6 +51,30 @@ export default defineConfig({ port: 5173, host: true, open: true, + cors: { + origin: true, + credentials: true, + methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"], + allowedHeaders: [ + "Authorization", + "Content-Type", + "X-DashScope-SSE", + "X-Requested-With", + ], + }, + proxy: { + "/dashscope-proxy": { + target: "https://dashscope.aliyuncs.com", + changeOrigin: true, + secure: true, + rewrite: (path) => path.replace(/^\/dashscope-proxy/, ""), + configure: (proxy) => { + proxy.on("proxyReq", (proxyReq) => { + proxyReq.setHeader("origin", "https://dashscope.aliyuncs.com"); + }); + }, + }, + }, }, preview: { port: 5173,