Merge branch 'codex/fix-public-landing-clean'

This commit is contained in:
t.indorf
2026-05-18 16:56:45 +02:00
3 changed files with 29 additions and 15 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ const geistMono = Geist_Mono({
export const metadata: Metadata = {
metadataBase: new URL(
process.env.NEXT_PUBLIC_SITE_URL ?? "https://kita-planer.example.com",
process.env.NEXT_PUBLIC_SITE_URL ?? "https://mein-kitaplaner.de",
),
title: {
default: "Der digitale Kita-Planer für Elternvereine",
+4 -10
View File
@@ -1,7 +1,6 @@
import type { Metadata } from "next";
import Image from "next/image";
import Link from "next/link";
import { redirect } from "next/navigation";
import {
ArrowRight,
CheckCircle2,
@@ -23,8 +22,6 @@ import {
UsersRound,
} from "lucide-react";
import { auth } from "@/auth";
import { getPostLoginRedirect } from "@/lib/post-login-redirect";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
@@ -41,6 +38,9 @@ export const metadata: Metadata = {
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
description:
"Die einfache Plattform für Elterninitiativen, freie Kitas und Kita-Vereine: organisiert Dienste, Termine, Krankmeldungen und offizielle Kommunikation an einem Ort.",
alternates: {
canonical: "/",
},
openGraph: {
title: "Kita-Planer für Elterninitiativen und Kita-Vereine",
description:
@@ -172,13 +172,7 @@ const onboardingSteps = [
},
];
// Eingeloggte User von der Landingpage direkt weiterleiten.
export default async function LandingPage() {
const session = await auth();
if (session?.user?.id) {
redirect(getPostLoginRedirect(session.user));
}
export default function LandingPage() {
return (
<div className="min-h-screen bg-[#f8faf8] text-slate-950">
<header className="absolute left-0 right-0 top-0 z-20">
+24 -4
View File
@@ -14,14 +14,31 @@ import { auth } from "@/auth";
// Eingeloggt + kein kitaId + nicht /onboarding → /onboarding
// Eingeloggt + SUPERADMIN → /admin
// Eingeloggt + hat kitaId + auf /onboarding → /dashboard
// Eingeloggt + auf /login oder /register → /
// Eingeloggt + auf /login oder /register → Post-Login-Ziel
// =====================================================================
const ONBOARDING_ROUTE = "/onboarding";
const PROTECTED_PREFIX = ["/dashboard", "/admin", "/onboarding"];
const PUBLIC_PATHS = new Set(["/", "/impressum", "/datenschutz"]);
const PUBLIC_PREFIX = ["/features"];
function getPostLoginPath(user: { role?: string; kitaId?: string | null }) {
if (user.role === "SUPERADMIN") {
return "/admin";
}
return user.kitaId ? "/dashboard" : ONBOARDING_ROUTE;
}
export async function proxy(request: NextRequest) {
const { pathname } = request.nextUrl;
const isPublicRoute =
PUBLIC_PATHS.has(pathname) ||
PUBLIC_PREFIX.some((prefix) => pathname.startsWith(prefix));
if (isPublicRoute) {
return NextResponse.next();
}
// Auth.js liest den Session-JWT aus dem Cookie —
// kein DB-Call, pure Token-Verifikation (Edge-sicher).
@@ -43,10 +60,12 @@ export async function proxy(request: NextRequest) {
// ── 2. Eingeloggt ───────────────────────────────────────────────────
if (hasValidUser && user) {
// 2a. Eingeloggter User auf Login/Register-Seite → Startseite,
// die dann selbst zu /dashboard oder /onboarding redirectet.
// 2a. Eingeloggter User auf Login/Register-Seite → direkt zum Ziel,
// damit die öffentliche Startseite stabil indexierbar bleibt.
if (pathname === "/login" || pathname === "/register") {
return NextResponse.redirect(new URL("/", request.nextUrl));
return NextResponse.redirect(
new URL(getPostLoginPath(user), request.nextUrl),
);
}
if (user.role === "SUPERADMIN" && pathname === ONBOARDING_ROUTE) {
@@ -58,6 +77,7 @@ export async function proxy(request: NextRequest) {
if (
!user.kitaId &&
user.role !== "SUPERADMIN" &&
isProtectedRoute &&
!pathname.startsWith(ONBOARDING_ROUTE)
) {
return NextResponse.redirect(new URL(ONBOARDING_ROUTE, request.nextUrl));