车辆管理系统-后台管理系统web
spring
4 天以前 9a11bff3d98aea29f37abc34a00a17f5c92ade9c
src/utils/settingMer.js
@@ -8,16 +8,36 @@
// | Author: CMS Team <admin@CMS.com>
// +----------------------------------------------------------------------
// 请求接口地址 如果没有配置自动获取当前网址路径
const VUE_APP_API_URL = process.env.VUE_APP_BASE_API || `${location.origin}`
const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || (location.protocol === 'https' ? 'wss' : 'ws') + ':' + location.hostname
// 请求接口地址
// 说明:生产环境下不希望使用“当前前端端口”,而应直接走后端端口 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: VUE_APP_API_URL + '/api/',
  apiBaseURL,
  // socket连接
  wsSocketUrl: VUE_APP_WS_URL
}
  wsSocketUrl: VUE_APP_WS_URL,
};
export default SettingMer