浏览代码

fix(config): 对特定域名请求禁用withCredentials

对于gpt4.cocorobo.cn和appapi.cocorobo.cn的请求,需要禁用withCredentials以避免跨域问题
lsc 1 周之前
父节点
当前提交
dfd9b2464c
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/services/config.ts

+ 4 - 0
src/services/config.ts

@@ -16,6 +16,10 @@ instance.interceptors.request.use(
     // 确保每个请求都带上cookie
     config.withCredentials = true
 
+    if (url.includes('https://gpt4.cocorobo.cn') || url.includes('https://appapi.cocorobo.cn')) {
+      config.withCredentials = false 
+    }
+
     // 需要 form-urlencoded 且 data 为数组的情况
     if (
       config.method === 'post' &&