From 5cb0cf0f3c4b996972c1eca7d68da26e0777b635 Mon Sep 17 00:00:00 2001 From: cherry2250 Date: Fri, 31 Oct 2025 15:06:51 +0900 Subject: [PATCH] mobile2 --- .../[eventId]/ai-recommendations/route.ts | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/app/api/events/[eventId]/ai-recommendations/route.ts diff --git a/src/app/api/events/[eventId]/ai-recommendations/route.ts b/src/app/api/events/[eventId]/ai-recommendations/route.ts new file mode 100644 index 0000000..1605953 --- /dev/null +++ b/src/app/api/events/[eventId]/ai-recommendations/route.ts @@ -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 } + ); + } +}