mirror of
https://github.com/ktds-dg0501/kt-event-marketing-fe.git
synced 2025-12-06 18:46:24 +00:00
Compare commits
4 Commits
948eb06e71
...
45ffd96090
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45ffd96090 | ||
|
|
6bd54bf42e | ||
|
|
12d390b1c8 | ||
|
|
5cb0cf0f3c |
@ -20,11 +20,6 @@ const nextConfig = {
|
||||
source: '/api/proxy/: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*',
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
100
src/app/api/events/[eventId]/ai-recommendations/route.ts
Normal file
100
src/app/api/events/[eventId]/ai-recommendations/route.ts
Normal 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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -8,29 +8,19 @@ export async function POST(
|
||||
) {
|
||||
try {
|
||||
const { eventId } = params;
|
||||
const token = request.headers.get('Authorization');
|
||||
const body = await request.json();
|
||||
|
||||
console.log('🎰 [Proxy] Draw winners request:', {
|
||||
eventId,
|
||||
hasToken: !!token,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
|
||||
if (!token) {
|
||||
return NextResponse.json(
|
||||
{ message: '인증 토큰이 필요합니다.' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`${GATEWAY_HOST}/api/v1/participations/events/${eventId}/draw-winners`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: token,
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ import type {
|
||||
* 현재는 apiClient를 사용하되, baseURL을 오버라이드합니다.
|
||||
*/
|
||||
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 클라이언트
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user