Firebase was not configured so every chat request crashed with 'Firebase Admin credentials not configured'. - chat-mode-resolver.ts: read project phase from fs_projects (Postgres) - chat-context.ts: load project data from fs_projects instead of Firestore - /api/ai/conversation: store/retrieve conversations in chat_conversations Postgres table (created automatically on first use) - /api/ai/chat: replace all Firestore reads/writes with Postgres queries - v_ai_chat/page.tsx: replace Firebase client auth with useSession from next-auth/react; remove Firestore listeners, use REST API for project data Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { useSession } from "next-auth/react";
|
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
import { useEffect, Suspense } from "react";
|
|
import NextAuthComponent from "@/app/components/NextAuthComponent";
|
|
|
|
function AuthPageInner() {
|
|
const { status } = useSession();
|
|
const router = useRouter();
|
|
const searchParams = useSearchParams();
|
|
|
|
useEffect(() => {
|
|
if (status === "authenticated") {
|
|
const callbackUrl = searchParams.get("callbackUrl");
|
|
// Only follow external callbackUrls we control (Theia subdomain)
|
|
if (callbackUrl && callbackUrl.startsWith("https://theia.vibnai.com")) {
|
|
window.location.href = callbackUrl;
|
|
} else {
|
|
router.push("/marks-account/projects");
|
|
}
|
|
}
|
|
}, [status, router, searchParams]);
|
|
|
|
if (status === "loading") {
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center bg-background">
|
|
<div className="text-center">
|
|
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4" />
|
|
<p className="text-muted-foreground">Loading authentication...</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <NextAuthComponent />;
|
|
}
|
|
|
|
export default function AuthPage() {
|
|
return (
|
|
<Suspense>
|
|
<AuthPageInner />
|
|
</Suspense>
|
|
);
|
|
}
|