const baseUrl = (process.env.CEFENSE_URL ?? "http://127.0.0.1:8080").replace(/\/$/, ""); async function request(path) { const response = await fetch(`${baseUrl}${path}`, { redirect: "manual" }); const contentType = response.headers.get("content-type") ?? ""; const body = contentType.includes("application/json") ? await response.json() : await response.text(); if (!response.ok) { throw new Error(`${path} returned ${response.status}: ${JSON.stringify(body)}`); } return { response, body }; } const home = await request("/"); if (typeof home.body !== "string" || !home.body.includes('id="root"')) { throw new Error("The frontend did not return the React shell."); } const directRoute = await request("/product"); if (typeof directRoute.body !== "string" || !directRoute.body.includes('id="root"')) { throw new Error("The SPA fallback did not serve a direct React route."); } const health = (await request("/health")).body; if (!health?.ok || !health?.dbConfigured || !health?.authConfigured) { throw new Error(`Backend health is incomplete: ${JSON.stringify(health)}`); } const auth = (await request("/auth/me")).body; if (!auth?.user?.email || !auth?.configured) { throw new Error(`Authentication did not resolve: ${JSON.stringify(auth)}`); } const me = (await request("/api/me")).body; if (!me?.dbConfigured || !me?.profile?.id || me.profile.email !== auth.user.email) { throw new Error(`Frontend → backend → database flow failed: ${JSON.stringify(me)}`); } const projects = (await request("/api/github/projects")).body; if (!Array.isArray(projects?.projects)) { throw new Error(`Projects response is malformed: ${JSON.stringify(projects)}`); } console.log( JSON.stringify( { ok: true, baseUrl, user: auth.user.email, profileId: me.profile.id, projectCount: projects.projects.length, }, null, 2, ), );