| 1 | import type { Metadata } from "next"; |
| 2 | import { cookies } from "next/headers"; |
| 3 | import { headers } from "next/headers"; |
| 4 | import { RingInstanceList } from "./ring-instance-list"; |
| 5 | |
| 6 | export const metadata: Metadata = { |
| 7 | title: "Ring", |
| 8 | }; |
| 9 | |
| 10 | export default async function RingHomePage() { |
| 11 | const cookieStore = await cookies(); |
| 12 | const signedIn = cookieStore.has("grove_hub_token"); |
| 13 | const headerStore = await headers(); |
| 14 | const host = |
| 15 | headerStore.get("x-forwarded-host") ?? |
| 16 | headerStore.get("host") ?? |
| 17 | ""; |
| 18 | const protocol = headerStore.get("x-forwarded-proto") ?? "http"; |
| 19 | const canonicalHost = host.split(",")[0]?.trim() ?? ""; |
| 20 | const groveHost = canonicalHost.replace(/^(canopy|ring)\./, ""); |
| 21 | const groveOrigin = groveHost ? `${protocol}://${groveHost}` : ""; |
| 22 | |
| 23 | return <RingInstanceList signedOut={!signedIn} groveOrigin={groveOrigin} />; |
| 24 | } |
| 25 | |