apps/web: Next.js 16 (App Router), Tailwind 4 and shadcn/ui, light and dark from the system. Pages render on the server and call the API with Eden Treaty (typed by @t5de/api), forwarding the visitor's cookie; forms use server actions; sign-up, sign-in and sign-out use Better Auth's React client. /api is rewritten to the API so its cookies are first-party. Who's online follows the API's event stream (Next's gzip is off: it held the stream back). Standalone output with a Dockerfile; deploys to Vercel as is. Co-Authored-By: Claude Opus 5.5 <[email protected]>
21 lines
846 B
TypeScript
21 lines
846 B
TypeScript
import type { Metadata } from "next";
|
|
import { redirect } from "next/navigation";
|
|
import { getMe } from "@/lib/api";
|
|
import { DeviceForm } from "./device-form";
|
|
|
|
export const metadata: Metadata = { title: "Sign T5DE in" };
|
|
|
|
type Search = { user_code?: string | string[]; code?: string | string[] };
|
|
|
|
export default async function Device({ searchParams }: { searchParams: Promise<Search> }) {
|
|
const search = await searchParams;
|
|
// Better Auth's verification link carries user_code; ?code= is shorter to type.
|
|
const code = [search.user_code, search.code].find((c) => typeof c === "string") ?? "";
|
|
const me = await getMe();
|
|
if (!me) {
|
|
const here = code ? `/device?code=${encodeURIComponent(code)}` : "/device";
|
|
redirect(`/signin?next=${encodeURIComponent(here)}`);
|
|
}
|
|
return <DeviceForm code={code} username={me.username} />;
|
|
}
|