import Vue from 'vue';
import getEnv from './get-env';
export const isServer = Vue.prototype.$isServer;

if (isServer) {
  Vue.prototype.$isSSR = true;
}

export let UMS_URL = '';
export let REQUEST_RUL = '';
export function isSSR() {
  return Vue.prototype.$isServer || Vue.prototype.$isSSR;
}

if (!isServer) {
  const env = getEnv(location.origin);

  if (env === 'production') {
    REQUEST_RUL = 'https://www.gaoding.com';
    UMS_URL = 'https://ums.gaoding.com';
  } else if (env === 'release') {
    REQUEST_RUL = 'https://stage.gaoding.com';
    UMS_URL = 'https://ums.gaoding.com';
  } else if (env === 'localhost') {
    REQUEST_RUL = 'http://www.gaoding.localhost';
    UMS_URL = 'http://ums.dev.gaoding.com';
  } else {
    REQUEST_RUL = 'http://www.dev.gaoding.com';
    UMS_URL = 'http://ums.dev.gaoding.com';
  }
}