Archives for : 七月2024

第1293天:开发环境和生产环境复杂接口场景

由于历史原因,接口有点混乱,有的是开发环境和生产环境共用,有的有区分,被逼出了这么个解决方案,看上去不会出错了。

// 环境判断
const isProdEnv = xxxxxxx

// 域名列表
const server = ‘https://server.xxx.chat/’
const test = ‘https://test.xxx.chat/’
const www = ‘https://www.xxx.chat/’
const wx = ‘https://wx.xxx.chat/’
const api = ‘https://api.xxx.chat/’

export const baseUrls = {
basic: isProdEnv ? server : test,
login: isProdEnv ? www : www,
scene: isProdEnv ? www : wx,
message: isProdEnv ? server : server,
redirect: isProdEnv ? www : test,
pay: isProdEnv ? api : api,
socket: isProdEnv ? www : www,
}