fix: add city rooms proxy route
This commit is contained in:
30
apps/web/src/app/api/city/rooms/route.ts
Normal file
30
apps/web/src/app/api/city/rooms/route.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
const API_BASE = process.env.CITY_API_BASE_URL || process.env.INTERNAL_API_URL;
|
||||||
|
|
||||||
|
export async function GET(_req: NextRequest) {
|
||||||
|
if (!API_BASE) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "CITY_API_BASE_URL is not configured" },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_BASE}/city/rooms`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
cache: "no-store",
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json().catch(() => null);
|
||||||
|
return NextResponse.json(data, { status: res.status });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("City rooms proxy error:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Failed to fetch city rooms" },
|
||||||
|
{ status: 502 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user