debug(gis-search): log session presence + access token presence

Temporary diagnostic for Faza E debugging — Marius reports search
returning "Eroare la căutare" after relogin. Need to confirm whether
session.accessToken is reaching the route.

Will revert/clean up once cause identified.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude VM
2026-05-18 21:30:24 +03:00
parent 99a673de3d
commit 7a22b11b54
+14
View File
@@ -7,6 +7,17 @@ export const dynamic = "force-dynamic";
export async function GET(request: Request) { export async function GET(request: Request) {
const session = await getAuthSession(); const session = await getAuthSession();
const hasSession = !!session;
const sessionUserEmail = session?.user?.email ?? null;
const hasAccessToken = !!(session as { accessToken?: string } | null)
?.accessToken;
console.log(
"[gis-search] hasSession=%s email=%s hasAccessToken=%s",
hasSession,
sessionUserEmail,
hasAccessToken,
);
if (!session) { if (!session) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
} }
@@ -22,14 +33,17 @@ export async function GET(request: Request) {
try { try {
const data = await gisApi.search(q, limit); const data = await gisApi.search(q, limit);
console.log("[gis-search] OK q=%s uats=%d features=%d", q, data.uats?.length ?? 0, data.features?.length ?? 0);
return NextResponse.json(data); return NextResponse.json(data);
} catch (err) { } catch (err) {
if (err instanceof GisApiError) { if (err instanceof GisApiError) {
console.error("[gis-search] gis-api error code=%s status=%d body=%j", err.code, err.status, err.body);
return NextResponse.json( return NextResponse.json(
{ error: err.code, status: err.status }, { error: err.code, status: err.status },
{ status: err.status }, { status: err.status },
); );
} }
console.error("[gis-search] internal error:", err);
return NextResponse.json({ error: "internal_error" }, { status: 500 }); return NextResponse.json({ error: "internal_error" }, { status: 500 });
} }
} }