import { headers } from "next/headers"; import { redirect } from "next/navigation"; import { issueSsoTicket } from "@/lib/auth/sso-ticket"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import { siteSettings } from "@/lib/services/site-settings"; export const dynamic = "force-dynamic"; export default async function ClientPage() { const session = await auth(); if (!session?.user?.id) redirect("/login"); const userId = Number(session.user.id); const [hotelName, clientUrl] = await Promise.all([ siteSettings.get("hotel_name", "Atom"), siteSettings.get("nitro_client_url", ""), ]); const hdrs = await headers(); const ip = hdrs.get("x-forwarded-for")?.split(",")[0]?.trim() ?? hdrs.get("x-real-ip") ?? "0.0.0.0"; // Faithful to AtomCMS's NitroController: issue (and persist) the SSO ticket on // the launcher render, then hand it to the client. const ticket = await issueSsoTicket(prisma, userId, hotelName ?? "Atom", ip); const src = clientUrl ? `${clientUrl}${clientUrl.includes("?") ? "&" : "?"}sso=${encodeURIComponent(ticket)}` : ""; return (

Launching {hotelName ?? "Atom"}…

{src ? (