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:
@@ -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}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user