CORS 에러 해결 및 Event API Mock 구현

- next.config.js: Event API 프록시 설정 추가 (8080 포트)
- eventApi.ts: 개발 환경에서 상대 경로 사용하도록 수정
- Mock API 추가: /api/v1/events/objectives (백엔드 준비 전 임시)
This commit is contained in:
merrycoral
2025-10-29 17:49:50 +09:00
parent f414e1e1dd
commit ddc7bc143f
3 changed files with 78 additions and 1 deletions
+7 -1
View File
@@ -29,11 +29,17 @@ const EVENT_HOST = process.env.NEXT_PUBLIC_EVENT_HOST || 'http://localhost:8080'
/**
* Event Service용 API 클라이언트
* Event Service는 별도 포트(8080)에서 실행되므로 별도 클라이언트 생성
*
* 로컬 개발 환경: Next.js rewrites 프록시 사용 (CORS 회피)
* 프로덕션 환경: 환경 변수에서 직접 호스트 사용
*/
import axios from 'axios';
const isProduction = process.env.NODE_ENV === 'production';
const API_BASE_URL = isProduction ? EVENT_HOST : ''; // 개발 환경에서는 상대 경로 사용
const eventApiClient = axios.create({
baseURL: EVENT_HOST,
baseURL: API_BASE_URL,
timeout: 30000,
headers: {
'Content-Type': 'application/json',