/** * Get the API Url, based on a hint in the current Url. */ function getApiUrl() { var prodUrl = 'https://api.cooltrax.com'; // use this if we can't compute it var hostname = window.location.hostname; var apiUrl = prodUrl; if (hostname.indexOf('-dev') !== -1) { apiUrl = 'https://api-dev.np.cooltrax.com'; } else if (hostname.indexOf('-uat') !== -1) { apiUrl = 'https://api-uat.np.cooltrax.com'; } return apiUrl; }