Merge pull request #25 from vinland100/fix/dashscope-cors-error
fix: route dashscope calls through dev proxy to avoid CORS
This commit is contained in:
commit
83fe1ad228
|
|
@ -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<LLMResponse> {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue