feat(F-069): completed feature
This commit is contained in:
16
project/frontend/src/app/api/shipping/methods/route.ts
Normal file
16
project/frontend/src/app/api/shipping/methods/route.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://127.0.0.1:3000';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const qs = searchParams.toString();
|
||||
const url = `${API}/shipping/methods${qs ? `?${qs}` : ''}`;
|
||||
try {
|
||||
const res = await fetch(url, { cache: 'no-store' });
|
||||
const body = await res.json().catch(() => ({ items: [] }));
|
||||
return NextResponse.json(body, { status: res.status });
|
||||
} catch {
|
||||
return NextResponse.json({ items: [] }, { status: 502 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user