← back to Homesonspec

apps/web/src/app/api/search/route.ts

19 lines

import { NextRequest, NextResponse } from "next/server";
import { runSearch } from "@homesonspec/search";
import { parseSearchParams } from "../../../lib/parse-search";

export const dynamic = "force-dynamic";

export async function GET(request: NextRequest) {
  const params = parseSearchParams(request.nextUrl.searchParams);
  const result = await runSearch(params);
  // Media-rights gate at the app boundary — same env the homepage reads. When
  // images are not licensed-on, blank them so the storefront darkens together
  // (never leak builder photos past the BUILDER_IMAGES_ENABLED gate). See
  // docs/data-rights/POLICY.md.
  if (process.env.BUILDER_IMAGES_ENABLED !== "1") {
    result.homes = result.homes.map((h) => ({ ...h, images: [] }));
  }
  return NextResponse.json(result);
}