33 lines
827 B
TypeScript
33 lines
827 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
const API_BASE_URL = process.env.API_BASE_URL || process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
|
|
// Public builds endpoint - no auth required
|
|
const res = await fetch(
|
|
`${API_BASE_URL}/api/v1/builds?${searchParams}`,
|
|
{
|
|
headers: { 'Content-Type': 'application/json' },
|
|
cache: 'no-store',
|
|
}
|
|
);
|
|
|
|
if (!res.ok) {
|
|
return NextResponse.json(
|
|
{ error: await res.text() },
|
|
{ status: res.status }
|
|
);
|
|
}
|
|
|
|
return NextResponse.json(await res.json());
|
|
} catch (err: any) {
|
|
return NextResponse.json(
|
|
{ error: err?.message || 'Failed to fetch builds' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|