File size: 1,737 Bytes
d97b8f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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})`);