woof. killed useClient and use nextjs api
CI / test (push) Successful in 5s

This commit is contained in:
2026-01-25 13:40:10 -05:00
parent 5b73d59c2c
commit 50ef395a38
19 changed files with 696 additions and 247 deletions
+8 -9
View File
@@ -18,8 +18,7 @@ type BuildDto = {
updatedAt?: string | null;
};
const API_BASE_URL =
process.env.NEXT_PUBLIC_API_BASE_URL ?? "";
// API routes now handled by Next.js /api routes (server-side)
// UUID validator (defensive)
const isUuid = (v: string) =>
@@ -40,14 +39,14 @@ export default function VaultPage() {
// NOTE:
// - `loading` here is AuthContext hydration, not network.
// - `token` is the real gate for /me endpoints.
const { user, token, loading: authLoading } = useAuth();
// - Auth is handled by HTTP-only cookies automatically.
const { user, loading: authLoading } = useAuth();
const [builds, setBuilds] = useState<BuildDto[]>([]);
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const authed = !!user && !!token;
const authed = !!user;
// Redirect if not logged in (after auth hydrates)
useEffect(() => {
@@ -56,12 +55,12 @@ export default function VaultPage() {
}
}, [authLoading, authed, router]);
// When auth identity changes, clear stale list to avoid ghost builds
// When auth identity changes, clear stale list to avoid "ghost builds"
useEffect(() => {
if (authLoading) return;
setBuilds([]);
setError(null);
}, [authLoading, user?.uuid, token]);
}, [authLoading, user?.uuid]);
// Fetch user builds
useEffect(() => {
@@ -75,8 +74,8 @@ export default function VaultPage() {
try {
// IMPORTANT:
// Use api wrapper so Authorization: Bearer <token> is consistently applied.
const res = await api.get("/api/v1/builds/me");
// Use api wrapper which includes credentials (cookies) automatically.
const res = await api.get("/api/builds");
if (!res.ok) {
const text = await res.text().catch(() => "");