// +----------------------------------------------------------------------
|
// | CMS [ CMS赋能开发者,助力企业发展 ]
|
// +----------------------------------------------------------------------
|
// | Copyright (c) 2016~2021 https://www.CMS.com All rights reserved.
|
// +----------------------------------------------------------------------
|
// | Licensed CMS并不是自由软件,未经许可不能去掉CMS相关版权
|
// +----------------------------------------------------------------------
|
// | Author: CMS Team <admin@CMS.com>
|
// +----------------------------------------------------------------------
|
|
// 请求接口地址
|
// 说明:生产环境下不希望使用“当前前端端口”,而应直接走后端端口 9031。
|
const DEFAULT_API_PORT = process.env.VUE_APP_API_PORT || 9031;
|
|
const VUE_APP_API_URL =
|
process.env.VUE_APP_BASE_API ||
|
(typeof location !== "undefined"
|
? `${location.protocol}//${location.hostname}:${DEFAULT_API_PORT}`
|
: `http://127.0.0.1:${DEFAULT_API_PORT}`);
|
|
// 支持用户传入的 VUE_APP_BASE_API 已经包含 /api 的情况,避免拼成双 /api
|
const apiBaseURL = VUE_APP_API_URL.includes("/api")
|
? VUE_APP_API_URL.endsWith("/") ? VUE_APP_API_URL : `${VUE_APP_API_URL}/`
|
: `${VUE_APP_API_URL.replace(/\/+$/, "")}/api/`;
|
|
const VUE_APP_WS_URL =
|
process.env.VUE_APP_WS_URL ||
|
(typeof location !== "undefined"
|
? `${
|
location.protocol === "https" ? "wss" : "ws"
|
}://${location.hostname}:${DEFAULT_API_PORT}`
|
: `ws://127.0.0.1:${DEFAULT_API_PORT}`);
|
|
const SettingMer = {
|
// 服务器地址
|
httpUrl: VUE_APP_API_URL,
|
// 接口请求地址
|
apiBaseURL,
|
// socket连接
|
wsSocketUrl: VUE_APP_WS_URL,
|
};
|
|
export default SettingMer
|