Merge branch 'main' into front

This commit is contained in:
yyoooona
2025-06-19 09:25:23 +09:00
committed by GitHub
15 changed files with 1091 additions and 384 deletions
+4 -5
View File
@@ -1,4 +1,3 @@
//* public/index.html
<!DOCTYPE html>
<html lang="ko">
<head>
@@ -29,14 +28,14 @@
rel="stylesheet"
/>
<title>test</title>
<!-- 런타임 환경 설정 -->
<script src="/runtime-env.js"></script>
<title>AI 마케팅 - 소상공인을 위한 스마트 마케팅 솔루션</title>
</head>
<body>
<div id="app"></div>
<!-- 런타임 환경 설정 -->
<script src="/runtime-env.js"></script>
<!-- 앱 스크립트 -->
<script type="module" src="/src/main.js"></script>
+86 -37
View File
@@ -1,44 +1,88 @@
//* public/runtime-env.js - 백엔드 API 경로에 맞게 수정
console.log('=== RUNTIME-ENV.JS 로드됨 ===');
//* public/runtime-env.js - Production environment priority configuration
console.log('=== RUNTIME-ENV.JS LOADED ===');
// Production environment detection function
const isProduction = () => {
// Production environment detection logic
return window.location.hostname !== 'localhost' &&
window.location.hostname !== '127.0.0.1' &&
!window.location.hostname.includes('dev');
};
// Default ingress host setting (from deploy_env_vars)
const DEFAULT_INGRESS_HOST = 'smarketing.20.249.184.228.nip.io';
// Environment-specific API URL configuration
const getBaseUrl = () => {
if (isProduction()) {
// Production: use ingress host
return `http://${DEFAULT_INGRESS_HOST}`;
} else {
// Development: use localhost
return '';
}
};
const baseUrl = getBaseUrl();
window.__runtime_config__ = {
// ⚠️ 수정: 백엔드 API 구조에 맞게 URL 설정
AUTH_URL: 'http://localhost:8081/api/auth',
MEMBER_URL: 'http://localhost:8081/api/member',
STORE_URL: 'http://localhost:8082/api/store',
MENU_URL: 'http://localhost:8082/api/menu',
SALES_URL: 'http://localhost:8082/api/sales', // store 서비스
CONTENT_URL: 'http://localhost:8083/api/content',
RECOMMEND_URL: 'http://localhost:8084/api/recommendations', // ⚠️ 수정: 올바른 경로
// Use ingress host in production, localhost in development
AUTH_URL: isProduction() ?
`${baseUrl}/api/auth` :
'http://localhost:8081/api/auth',
MEMBER_URL: isProduction() ?
`${baseUrl}/api/member` :
'http://localhost:8081/api/member',
STORE_URL: isProduction() ?
`${baseUrl}/api/store` :
'http://localhost:8082/api/store',
MENU_URL: isProduction() ?
`${baseUrl}/api/menu` :
'http://localhost:8082/api/menu',
SALES_URL: isProduction() ?
`${baseUrl}/api/sales` :
'http://localhost:8082/api/sales',
CONTENT_URL: isProduction() ?
`${baseUrl}/api/content` :
'http://localhost:8083/api/content',
RECOMMEND_URL: isProduction() ?
`${baseUrl}/api/recommend` :
'http://localhost:8084/api/recommendations',
// Gateway URL (운영 환경용)
GATEWAY_URL: 'http://20.1.2.3',
// Gateway URL
GATEWAY_URL: isProduction() ? baseUrl : 'http://20.1.2.3',
// 기능 플래그
// Feature flags
FEATURES: {
ANALYTICS: true,
PUSH_NOTIFICATIONS: true,
SOCIAL_LOGIN: false,
MULTI_LANGUAGE: false,
API_HEALTH_CHECK: true, // ⚠️ 추가
API_HEALTH_CHECK: true,
},
// 환경 설정
ENV: 'development',
DEBUG: true,
// Environment settings
ENV: isProduction() ? 'production' : 'development',
DEBUG: !isProduction(),
// ⚠️ 추가: API 타임아웃 설정
// API timeout settings
API_TIMEOUT: 30000,
// ⚠️ 추가: 재시도 설정
// Retry settings
RETRY_ATTEMPTS: 3,
RETRY_DELAY: 1000,
// 버전 정보
// Version information
VERSION: '1.0.0',
BUILD_DATE: new Date().toISOString(),
// ⚠️ 추가: 백엔드 서비스 포트 정보 (디버깅용)
// Backend service port information (for debugging)
BACKEND_PORTS: {
AUTH: 8081,
STORE: 8082,
@@ -47,39 +91,41 @@ window.__runtime_config__ = {
}
};
// ⚠️ 추가: 설정 검증 함수
// Configuration 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(`❌ [CONFIG] 필수 URL 누락: ${url}`);
console.error(`Missing required URL: ${url}`);
return false;
}
}
console.log('✅ [CONFIG] 설정 검증 완료');
console.log('Config validation completed');
return true;
};
// ⚠️ 추가: 개발 환경에서만 상세 로깅
// Environment-specific detailed logging
if (window.__runtime_config__.DEBUG) {
console.log('=== 백엔드 API URLs ===');
console.log('🔐 AUTH_URL:', window.__runtime_config__.AUTH_URL);
console.log('🏪 STORE_URL:', window.__runtime_config__.STORE_URL);
console.log('📊 SALES_URL:', window.__runtime_config__.SALES_URL);
console.log('🤖 RECOMMEND_URL:', window.__runtime_config__.RECOMMEND_URL);
console.log('📄 CONTENT_URL:', window.__runtime_config__.CONTENT_URL);
console.log('=== Current Environment Info ===');
console.log('Environment:', window.__runtime_config__.ENV);
console.log('Hostname:', window.location.hostname);
console.log('Is Production:', isProduction());
console.log('=== 설정 상세 정보 ===');
console.log('전체 설정:', window.__runtime_config__);
console.log('=== Backend API URLs ===');
console.log('AUTH_URL:', window.__runtime_config__.AUTH_URL);
console.log('STORE_URL:', window.__runtime_config__.STORE_URL);
console.log('SALES_URL:', window.__runtime_config__.SALES_URL);
console.log('RECOMMEND_URL:', window.__runtime_config__.RECOMMEND_URL);
console.log('CONTENT_URL:', window.__runtime_config__.CONTENT_URL);
// 설정 검증 실행
validateConfig();
console.log('=== Detailed Configuration ===');
console.log('Full config:', window.__runtime_config__);
}
// ⚠️ 추가: 전역 설정 접근 함수
// Global configuration access functions
window.getApiConfig = () => window.__runtime_config__;
window.getApiUrl = (serviceName) => {
const config = window.__runtime_config__;
@@ -87,4 +133,7 @@ window.getApiUrl = (serviceName) => {
return config[urlKey] || null;
};
console.log('✅ [RUNTIME] 런타임 설정 로드 완료');
// Execute configuration validation
validateConfig();
console.log(`Runtime configuration loaded successfully (${window.__runtime_config__.ENV} environment)`);