- TopNav: 홈/샘플/팩 상세/스튜디오 4개 링크 구조 - /services/music: 컴팩트 헤더 + PRICING 최상단 배치 (상세 포맷) - /studio: Suno Generate UI (simple/custom 모드, 태그 프리셋, 폴링) - /api/studio/generate, /api/studio/status: Suno API 프록시
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
export async function GET(request: Request) {
|
|
const apiUrl = process.env.SUNO_API_URL;
|
|
const apiKey = process.env.SUNO_API_KEY;
|
|
|
|
if (!apiUrl || !apiKey) {
|
|
return NextResponse.json(
|
|
{ error: 'Suno API 미설정 (SUNO_API_URL / SUNO_API_KEY 환경변수 필요)' },
|
|
{ status: 503 },
|
|
);
|
|
}
|
|
|
|
const { searchParams } = new URL(request.url);
|
|
const ids = searchParams.get('ids');
|
|
if (!ids) return NextResponse.json({ error: 'ids required' }, { status: 400 });
|
|
|
|
try {
|
|
const res = await fetch(
|
|
`${apiUrl.replace(/\/$/, '')}/api/get?ids=${encodeURIComponent(ids)}`,
|
|
{ headers: { Authorization: `Bearer ${apiKey}` } },
|
|
);
|
|
const data = await res.json().catch(() => null);
|
|
if (!res.ok) {
|
|
return NextResponse.json(
|
|
{ error: '조회 실패', detail: data },
|
|
{ status: res.status },
|
|
);
|
|
}
|
|
return NextResponse.json({ ok: true, data });
|
|
} catch (e) {
|
|
return NextResponse.json(
|
|
{ error: '조회 오류', detail: e instanceof Error ? e.message : String(e) },
|
|
{ status: 502 },
|
|
);
|
|
}
|
|
}
|