Files
Epicnabbo-Catalogus-Updated…/src/app/client/page.tsx
T
Simo 56cd6fd058 Fix Nitro client launcher: read the nitro_path setting
The /client launcher read a non-existent `nitro_client_url` setting, so it
always fell through to "No client configured" and the client never launched.
Faithful to AtomCMS's NitroController + nitro.blade.php, build the launch URL
as {nitro_path}/index.html?sso=<ticket> plus the toolbar colour params, via a
shared buildNitroClientUrl helper. The Flash launcher's Nitro fallback used the
same dead key and is fixed too.
2026-06-29 21:10:44 +02:00

62 lines
2.1 KiB
TypeScript

import Link from "next/link";
import { headers } from "next/headers";
import { redirect } from "next/navigation";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
import { buildNitroClientUrl } from "@/lib/services/clients";
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 = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
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 Nitro client at {nitro_path}.
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
const src = await buildNitroClientUrl(ticket);
return (
<main style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon="🏨"
title={`Launching ${hotelName}…`}
subtitle="Your single sign-on ticket is ready"
action={
<Link href="/client/flash" className="btn btn-outline">
Use Flash client
</Link>
}
/>
{src ? (
<ContentCard padded={false}>
<iframe
title="Hotel client"
src={src}
style={{ width: "100%", height: "85vh", border: 0, borderRadius: 10, display: "block" }}
/>
</ContentCard>
) : (
<ContentCard icon="🔌" title="No client configured" subtitle="Set nitro_path in settings">
<EmptyState icon="🔌">
No Nitro client configured — set <code>nitro_path</code> (e.g.{" "}
<code>/Nitro-V3/dist</code>) in the admin settings. SSO ticket issued for this session:{" "}
<code>{ticket}</code>
</EmptyState>
</ContentCard>
)}
</main>
);
}