Files
9router/src/app/api/providers/client/route.js
T

22 lines
872 B
JavaScript
Raw Normal View History

2026-01-05 09:58:59 +07:00
import { NextResponse } from "next/server";
import { getProviderConnections } from "@/lib/localDb";
import { backfillCodexEmails } from "@/lib/oauth/providers";
2026-01-05 09:58:59 +07:00
// GET /api/providers/client - List all connections for client (includes sensitive fields for sync)
export async function GET() {
try {
await backfillCodexEmails();
2026-01-05 09:58:59 +07:00
const connections = await getProviderConnections();
// Include sensitive fields for sync to cloud (only accessible from same origin)
const clientConnections = connections.map(c => ({
...c,
// Don't hide sensitive fields here since this is for internal sync
}));
return NextResponse.json({ connections: clientConnections });
} catch (error) {
console.log("Error fetching providers for client:", error);
return NextResponse.json({ error: "Failed to fetch providers" }, { status: 500 });
}
}