Guilherme34's picture
Upload folder using huggingface_hub
aa15bce verified
raw
history blame
1.07 kB
export const runtime = 'nodejs';
export async function POST(req: Request) {
let body: any = {};
try {
body = await req.json();
} catch {}
const userId = body?.userId || '';
const authConfigId = body?.authConfigId || '';
const serverBase = process.env.PY_SERVER_URL || 'http://localhost:8001';
const url = `${serverBase.replace(/\/$/, '')}/api/v1/gmail/connect`;
try {
const resp = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ user_id: userId, auth_config_id: authConfigId }),
});
const data = await resp.json().catch(() => ({}));
return new Response(JSON.stringify(data), {
status: resp.status,
headers: { 'Content-Type': 'application/json; charset=utf-8' },
});
} catch (e: any) {
return new Response(
JSON.stringify({ ok: false, error: 'Upstream error', detail: e?.message || String(e) }),
{ status: 502, headers: { 'Content-Type': 'application/json; charset=utf-8' } }
);
}
}