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:
@@ -7,6 +7,17 @@ export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
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) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
@@ -22,14 +33,17 @@ export async function GET(request: Request) {
|
||||
|
||||
try {
|
||||
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);
|
||||
} catch (err) {
|
||||
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(
|
||||
{ error: err.code, status: err.status },
|
||||
{ status: err.status },
|
||||
);
|
||||
}
|
||||
console.error("[gis-search] internal error:", err);
|
||||
return NextResponse.json({ error: "internal_error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user