index.js 417 B

123456789101112131415
  1. export function getApiBaseUrl (){
  2. const { protocol, hostname, port } = window.location;
  3. // 开发环境特殊处理
  4. if (hostname === 'localhost' || hostname === '127.0.0.1') {
  5. return 'http://localhost:8084/pdu'; // 开发服务器地址
  6. }
  7. // 生产环境使用当前域名
  8. return port
  9. ? `${protocol}//${hostname}:${port}/pdu`
  10. : `${protocol}//${hostname}/pdu`;
  11. }