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