diff --git a/app/lib/dashboard.ts b/app/lib/dashboard.ts index b185e92..a39d3fb 100644 --- a/app/lib/dashboard.ts +++ b/app/lib/dashboard.ts @@ -41,7 +41,9 @@ export async function api(path: string, init: RequestInit = {}) { const headers = new Headers(init.headers); headers.set("accept", "application/json"); if (init.body) headers.set("content-type", "application/json"); - Object.entries(DEMO_HEADERS).forEach(([key, value]) => headers.set(key, value)); + if (AUTH_MODE === "demo") { + Object.entries(DEMO_HEADERS).forEach(([key, value]) => headers.set(key, value)); + } const response = await fetch(`${API_BASE}${path}`, { ...init, headers, credentials: "include" }); const body = (await response.json().catch(() => ({}))) as T & { error?: string; detail?: string }; if (!response.ok) throw new Error(body.detail || body.error || `Request failed (${response.status})`); diff --git a/app/page.tsx b/app/page.tsx index 80dbbde..dd326c5 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,10 +1,24 @@ "use client"; +import { useEffect } from "react"; import Link from "next/link"; +import { useRouter } from "next/navigation"; import { ArrowRight, Boxes, FileArchive, Gauge, KeyRound, ShieldCheck, UploadCloud } from "lucide-react"; import { AUTH_MODE, API_BASE } from "@/app/lib/dashboard"; export default function Home() { + const router = useRouter(); + + // SSOモードでログイン済みなら、ランディングを挟まずダッシュボードへ向かう。 + useEffect(() => { + if (AUTH_MODE !== "oidc") return; + let cancelled = false; + fetch(`${API_BASE}/api/v1/me`, { credentials: "include" }) + .then((response) => { if (response.ok && !cancelled) router.replace("/dashboard"); }) + .catch(() => {}); + return () => { cancelled = true; }; + }, [router]); + return
AAltDockBETA @@ -24,7 +38,7 @@ export default function Home() { ダッシュボードを開く 配布要件を見る -
Demo mode で起動中 · API {API_BASE}
+ {AUTH_MODE === "demo" &&
Demo mode で起動中 · API {API_BASE}
}