fix: 小程序/H5 API 地址指向错误导致登录失败

- .env.production VITE_PROD_API_HOST 从旧域名 aicc.yzrcloud.cn 改为
  zhiyinwx.yzrcloud.cn
- config.ts api() 函数增加 MP-WEIXIN 编译分支,小程序直接使用
  VITE_PROD_API_HOST,H5 保持同源请求
This commit is contained in:
yuzhiran
2026-06-11 19:39:59 +08:00
parent c321a8dcb1
commit e021e194c4
1891 changed files with 31 additions and 5 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
# 生产环境变量
VITE_API_BASE_URL=https://aicc.yzrcloud.cn/api
VITE_API_BASE_URL=https://zhiyinwx.yzrcloud.cn/api
VITE_APP_NAME=AI磁场
VITE_PROD_API_HOST=https://aicc.yzrcloud.cn
VITE_PROD_API_HOST=https://zhiyinwx.yzrcloud.cn
+16 -3
View File
@@ -88,9 +88,22 @@ export const API_ENDPOINTS = {
},
} as const
const API_HOST = typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1'
? (import.meta.env.VITE_PROD_API_HOST || window.location.origin)
: 'http://localhost:3006'
const PROD_API_HOST = import.meta.env.VITE_PROD_API_HOST || 'https://zhiyinwx.yzrcloud.cn'
const DEV_API_HOST = 'http://localhost:3006'
let API_HOST: string
// #ifdef H5
API_HOST = window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1'
? window.location.origin
: DEV_API_HOST
// #endif
// #ifdef MP-WEIXIN
API_HOST = PROD_API_HOST
// #endif
// #ifndef H5 && !MP-WEIXIN
API_HOST = PROD_API_HOST
// #endif
export function api(path: string): string {
return `${API_HOST}/api${path}`
}