const sanitizeApiBaseUrl = (value?: string) => {
  if (!value) {
    return "";
  }

  return value
    .trim()
    .replace(/\/$/, "")
    .replace(/\/api$/, "");
};

export const getApiBaseUrl = () => {
  const envBaseUrl = sanitizeApiBaseUrl(process.env.NEXT_PUBLIC_API_BASE_URL);

  return envBaseUrl;
};

export const API_BASE_URL = getApiBaseUrl();
