Compare commits

...

4 Commits

Author SHA1 Message Date
cherry2250
45ffd96090 event 에러 수정 2025-10-31 15:22:37 +09:00
jhbkjh
6bd54bf42e proxy 삭제 2025-10-31 15:18:08 +09:00
jhbkjh
12d390b1c8 당첨자 추첨 인증토큰 검증 삭제 2025-10-31 15:10:09 +09:00
cherry2250
5cb0cf0f3c mobile2 2025-10-31 15:06:51 +09:00
4 changed files with 101 additions and 16 deletions

View File

@ -20,11 +20,6 @@ const nextConfig = {
source: '/api/proxy/:path*', source: '/api/proxy/:path*',
destination: 'http://localhost:8084/api/:path*', destination: 'http://localhost:8084/api/:path*',
}, },
// Event Service API Proxy (8080 포트)
{
source: '/api/v1/events/:path*',
destination: 'http://localhost:8080/api/v1/events/:path*',
},
] ]
}, },
} }

View File

@ -0,0 +1,100 @@
import { NextRequest, NextResponse } from 'next/server';
const EVENT_API_HOST =
process.env.NEXT_PUBLIC_EVENT_HOST || 'http://kt-event-marketing-api.20.214.196.128.nip.io';
const API_VERSION = process.env.NEXT_PUBLIC_API_VERSION || 'v1';
/**
* Event API Proxy: AI
* POST /api/events/{eventId}/ai-recommendations
*/
export async function POST(
request: NextRequest,
{ params }: { params: { eventId: string } }
) {
try {
const { eventId } = params;
const body = await request.json();
const backendUrl = `${EVENT_API_HOST}/api/${API_VERSION}/events/${eventId}/ai-recommendations`;
console.log('🤖 Proxying AI recommendation request to:', backendUrl);
console.log('📦 Request body:', body);
const backendResponse = await fetch(backendUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: request.headers.get('Authorization') || '',
},
body: JSON.stringify(body),
});
const data = await backendResponse.json();
console.log('✅ AI recommendation response:', {
status: backendResponse.status,
data: data,
});
return NextResponse.json(data, { status: backendResponse.status });
} catch (error) {
console.error('❌ AI recommendation POST proxy error:', error);
return NextResponse.json(
{
success: false,
errorCode: 'PROXY_ERROR',
message: 'AI 추천 요청 중 오류가 발생했습니다',
details: error instanceof Error ? error.message : 'Unknown error',
},
{ status: 500 }
);
}
}
/**
* Event API Proxy: AI
* GET /api/events/{eventId}/ai-recommendations
*/
export async function GET(
request: NextRequest,
{ params }: { params: { eventId: string } }
) {
try {
const { eventId } = params;
const backendUrl = `${EVENT_API_HOST}/api/${API_VERSION}/events/${eventId}/ai-recommendations`;
console.log('🔍 Proxying AI recommendation GET request to:', backendUrl);
const backendResponse = await fetch(backendUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: request.headers.get('Authorization') || '',
},
});
const data = await backendResponse.json();
console.log('✅ AI recommendation GET response:', {
status: backendResponse.status,
data: data,
});
return NextResponse.json(data, { status: backendResponse.status });
} catch (error) {
console.error('❌ AI recommendation GET proxy error:', error);
return NextResponse.json(
{
success: false,
errorCode: 'PROXY_ERROR',
message: 'AI 추천 결과 조회 중 오류가 발생했습니다',
details: error instanceof Error ? error.message : 'Unknown error',
},
{ status: 500 }
);
}
}

View File

@ -8,29 +8,19 @@ export async function POST(
) { ) {
try { try {
const { eventId } = params; const { eventId } = params;
const token = request.headers.get('Authorization');
const body = await request.json(); const body = await request.json();
console.log('🎰 [Proxy] Draw winners request:', { console.log('🎰 [Proxy] Draw winners request:', {
eventId, eventId,
hasToken: !!token,
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
}); });
if (!token) {
return NextResponse.json(
{ message: '인증 토큰이 필요합니다.' },
{ status: 401 }
);
}
const response = await fetch( const response = await fetch(
`${GATEWAY_HOST}/api/v1/participations/events/${eventId}/draw-winners`, `${GATEWAY_HOST}/api/v1/participations/events/${eventId}/draw-winners`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: token,
}, },
body: JSON.stringify(body), body: JSON.stringify(body),
} }

View File

@ -24,7 +24,7 @@ import type {
* apiClient를 , baseURL을 . * apiClient를 , baseURL을 .
*/ */
const EVENT_API_BASE = '/api/v1/events'; const EVENT_API_BASE = '/api/v1/events';
const EVENT_HOST = process.env.NEXT_PUBLIC_EVENT_HOST || 'http://localhost:8080'; const EVENT_HOST = 'http://kt-event-marketing-api.20.214.196.128.nip.io';
/** /**
* Event Service용 API * Event Service용 API