| |
| |
| |
| |
|
|
| |
| window.APP_CONFIG = { |
| |
| APP_NAME: 'KSTools License & Version Manager', |
| VERSION: '2.1.0', |
| |
| |
| SUPABASE_LICENSE_URL: null, |
| SUPABASE_LICENSE_ANON_KEY: null, |
| |
| |
| SUPABASE_VERSION_URL: null, |
| SUPABASE_VERSION_ANON_KEY: null, |
| |
| |
| CONFIG_LOADED: false |
| }; |
|
|
| |
| async function loadConfig() { |
| try { |
| |
| const isLocalDev = window.location.hostname === 'localhost' || |
| window.location.hostname === '127.0.0.1'; |
|
|
| console.log('🔄 Loading dual Supabase config...'); |
| const response = await fetch('/api/frontend-config'); |
| if (response.ok) { |
| const config = await response.json(); |
| window.APP_CONFIG = { ...window.APP_CONFIG, ...config }; |
| window.APP_CONFIG.CONFIG_LOADED = true; |
| console.log('✅ Config loaded:', { |
| hasLicenseUrl: !!config.SUPABASE_LICENSE_URL, |
| hasLicenseKey: !!config.SUPABASE_LICENSE_ANON_KEY, |
| hasVersionUrl: !!config.SUPABASE_VERSION_URL, |
| hasVersionKey: !!config.SUPABASE_VERSION_ANON_KEY |
| }); |
|
|
| |
| window.dispatchEvent(new CustomEvent('configLoaded', { detail: config })); |
| } else { |
| |
| if (isLocalDev) { |
| console.warn('⚠️ Config load failed - using dev mode'); |
| window.APP_CONFIG.CONFIG_LOADED = true; |
| window.dispatchEvent(new CustomEvent('configLoaded', { detail: {} })); |
| } else { |
| console.error('❌ Config load failed in production'); |
| window.APP_CONFIG.CONFIG_LOADED = false; |
| } |
| } |
| } catch (error) { |
| |
| const isLocalDev = window.location.hostname === 'localhost' || |
| window.location.hostname === '127.0.0.1'; |
|
|
| |
| if (isLocalDev) { |
| console.error('❌ Config error - using dev mode:', error); |
| window.APP_CONFIG.CONFIG_LOADED = true; |
| window.dispatchEvent(new CustomEvent('configLoaded', { detail: {} })); |
| } else { |
| console.error('❌ Config error in production:', error); |
| window.APP_CONFIG.CONFIG_LOADED = false; |
| } |
| } |
| } |
|
|
| |
| loadConfig(); |