Spaces:
Sleeping
Sleeping
| // Define API base URL based on environment | |
| // In development, use localhost | |
| // In production or other environments, use the Azure URL | |
| import { info } from '@/utils/debug'; | |
| const isMobileApp = () => { | |
| return typeof window !== 'undefined' && | |
| (window.location.href.includes('capacitor://') || | |
| window.location.href.includes('ionic://') || | |
| /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); | |
| }; | |
| const isDevelopment = process.env.NODE_ENV === 'development'; | |
| const isMobile = isMobileApp(); | |
| // Force development URL when explicitly requested via URL param (for testing) | |
| const forceLocalApi = typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('localApi') === 'true'; | |
| export const API_BASE_URL = | |
| // isMobile && !forceLocalApi | |
| // ? 'https://localhost:7094' // ✅ Use remote on mobile (unless forced to local) https://uatetextile.azurewebsites.net | |
| // : isDevelopment || forceLocalApi | |
| // ? 'https://localhost:7094' // Localhost for dev in browser | |
| // : 'https://localhost:7094'; | |
| // export const API_BASE_URL = | |
| isMobile && !forceLocalApi | |
| // ? 'https://pmtoolapi.synthesys.in' // ✅ Use remote on mobile (unless forced to local) https://uatetextile.azurewebsites.net | |
| ? 'https://pmtoolapi.synthesys.in' // ✅ Use remote on mobile (unless forced to local) https://uatetextile.azurewebsites.net | |
| : isDevelopment || forceLocalApi | |
| ? 'https://stagginpmtool.azurewebsites.net' // Localhost for dev in browser | |
| : 'https://pmtoolapi.synthesys.in'; | |
| // Log using the debug utility | |
| info.system(`Using API URL: ${API_BASE_URL} (${process.env.NODE_ENV} environment, Mobile: ${isMobile})`); |