smarketing-frontend/deployment/manifest/frontend-configmap.yaml
2025-06-18 14:52:48 +09:00

74 lines
2.1 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: smarketing-frontend-config
namespace: ${namespace}
data:
runtime-env.js: |
console.log('=== RUNTIME-ENV.JS LOADED (PRODUCTION) ===');
window.__runtime_config__ = {
// Backend API URLs using ingress host
AUTH_URL: 'http://${ingress_host}/api/auth',
MEMBER_URL: 'http://${ingress_host}/api/member',
STORE_URL: 'http://${ingress_host}/api/store',
MENU_URL: 'http://${ingress_host}/api/menu',
SALES_URL: 'http://${ingress_host}/api/sales',
CONTENT_URL: 'http://${ingress_host}/api/content',
RECOMMEND_URL: 'http://${ingress_host}/api/recommend',
// Gateway URL (production environment)
GATEWAY_URL: 'http://${ingress_host}',
// Feature flags
FEATURES: {
ANALYTICS: true,
PUSH_NOTIFICATIONS: true,
SOCIAL_LOGIN: false,
MULTI_LANGUAGE: false,
API_HEALTH_CHECK: true,
},
// Environment settings (production)
ENV: 'production',
DEBUG: false,
// API timeout settings
API_TIMEOUT: 30000,
// Retry settings
RETRY_ATTEMPTS: 3,
RETRY_DELAY: 1000,
// Version info
VERSION: '1.0.0',
BUILD_DATE: new Date().toISOString()
};
// Config validation function
const validateConfig = () => {
const config = window.__runtime_config__;
const requiredUrls = ['AUTH_URL', 'STORE_URL', 'SALES_URL', 'RECOMMEND_URL'];
for (const url of requiredUrls) {
if (!config[url]) {
console.error('Missing required URL: ' + url);
return false;
}
}
console.log('Config validation completed');
return true;
};
// Global config access functions
window.getApiConfig = () => window.__runtime_config__;
window.getApiUrl = (serviceName) => {
const config = window.__runtime_config__;
const urlKey = serviceName.toUpperCase() + '_URL';
return config[urlKey] || null;
};
// Execute validation
validateConfig();
console.log('Runtime config loaded successfully (PRODUCTION)');