const getTarget = () => {
  const env = process.env.DOMAIN_ENV;
  switch (env) {
    case 'gms':
      return 'https://gms.smatec.com.vn';
    case 'spole':
      return 'https://spole.gms.vn';
    case 'sgw':
      return 'https://sgw.gms.vn';
    default:
      return 'https://sgw.gms.vn';
  }
};

const target = getTarget();

const proxyDev: Record<string, any> = {
  dev: {
    '/api': {
      target: target,
      changeOrigin: true,
    },
    '/geoserver': {
      target: target,
      changeOrigin: true,
    },
    '/mqtt': {
      target: target,
      changeOrigin: true,
      ws: true,
    },
  },
  test: {
    '/test': {
      target: 'https://proapi.azurewebsites.net',
      changeOrigin: true,
      secure: false,
    },
  },
  prod: {
    '/test': {
      target: 'https://prod-sgw-device.gms.vn',
      changeOrigin: true,
      secure: false,
    },
  },
};

export default proxyDev;
