chore: release 0.0.1

This commit is contained in:
liaibo
2025-11-29 05:16:23 +08:00
parent 5d0e4c4cb6
commit d350b02fba
92 changed files with 78929 additions and 39164 deletions
@@ -1,5 +1,6 @@
"use client";
import { useEffect } from "react";
import type { Session } from "@supabase/supabase-js";
import { SessionContextProvider } from "@supabase/auth-helpers-react";
import { supabaseBrowser } from "@/lib/supabase/client";
@@ -10,6 +11,34 @@ interface SupabaseProviderProps {
}
export function SupabaseProvider({ session, children }: SupabaseProviderProps) {
useEffect(() => {
const {
data: { subscription },
} = supabaseBrowser.auth.onAuthStateChange((_event, newSession) => {
fetch("/api/auth/callback", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ event: _event, session: newSession }),
});
});
supabaseBrowser.auth.getSession().then(({ data }) => {
if (data.session) {
fetch("/api/auth/callback", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ event: "INITIAL_SESSION", session: data.session }),
});
}
});
return () => {
subscription.unsubscribe();
};
}, []);
return (
<SessionContextProvider supabaseClient={supabaseBrowser} initialSession={session}>
{children}