diff --git a/app/api/agent/route.ts b/app/api/agent/route.ts index 14e573b..cabbdcc 100644 --- a/app/api/agent/route.ts +++ b/app/api/agent/route.ts @@ -1058,6 +1058,7 @@ function hasInternalCronAuth(req: NextRequest): boolean { export async function POST(req: NextRequest): Promise { const body = (await req.clone().json().catch(() => ({}))) as { query?: string; + demo?: boolean; fallback?: boolean; }; const url = new URL(req.url); @@ -1087,6 +1088,15 @@ export async function POST(req: NextRequest): Promise { ); } + const query = (body.query ?? "").trim(); + const demoMode = + body.demo === true || + url.searchParams.get("demo") === "1" || + req.headers.get("x-txlookup-demo") === "1"; + if (demoMode && query && findFixture(query)) { + return handlePost(req); + } + const byok = req.cookies.get("txl_byok")?.value; if (byok && byok.startsWith("sk-")) { return runWithKey(byok, () => handlePost(req));