From a563ec86a0e753a4d34b6e02288e4bc05b493d84 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 1 Dec 2025 08:52:59 -0800 Subject: [PATCH] fix(rooms): Use rewrite for /api/city/rooms instead of API route - Removed API route that was conflicting with rewrite - Added explicit rewrite for /api/city/rooms -> /api/v1/city/rooms - Rewrite order matters: specific routes before wildcard --- apps/web/next.config.ts | 8 ++++++- apps/web/src/app/api/city/rooms/route.ts | 30 ------------------------ 2 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 apps/web/src/app/api/city/rooms/route.ts diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index c78fd5b4..e2f87b6f 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -41,12 +41,18 @@ const nextConfig: NextConfig = { source: '/api/public/:path*', destination: `${internalApiUrl}/public/:path*`, }, + // City Rooms API (list) -> /api/v1/city/rooms + // Note: This must be before /api/city/:path* to take precedence + { + source: '/api/city/rooms', + destination: `${internalApiUrl}/api/v1/city/rooms`, + }, // City Rooms API (specific slug endpoint) -> /api/v1/city/rooms { source: '/api/city/rooms/:slug', destination: `${internalApiUrl}/api/v1/city/rooms/:slug`, }, - // City API -> /city + // City API -> /city (excludes /api/city/rooms which is handled above) { source: '/api/city/:path*', destination: `${internalApiUrl}/city/:path*`, diff --git a/apps/web/src/app/api/city/rooms/route.ts b/apps/web/src/app/api/city/rooms/route.ts deleted file mode 100644 index 6b56f245..00000000 --- a/apps/web/src/app/api/city/rooms/route.ts +++ /dev/null @@ -1,30 +0,0 @@ -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}/api/v1/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 } - ); - } -} -