"use client"; import { useEffect, useState } from "react"; import { authFetch, clearToken, getApiBase } from "../lib/auth"; import "../welcome.css"; export default function WelcomePage() { const [ready, setReady] = useState(false); const [url, setUrl] = useState(null); const [error, setError] = useState(""); useEffect(() => { const controller = new AbortController(); void (async () => { try { const response = await authFetch(`${getApiBase()}/site/info`, { signal: controller.signal }); if (response.status === 401) { clearToken(); window.location.replace("/login"); return; } if (!response.ok) throw new Error("Unavailable"); const data = await response.json(); const candidate = data.mediaServerUrl ? new URL(data.mediaServerUrl) : null; if (candidate && ["https:", "http:"].includes(candidate.protocol) && !candidate.username && !candidate.password) setUrl(candidate.href); setReady(true); } catch { if (!controller.signal.aborted) setError("We couldn’t load your welcome page. Please try again."); } })(); return () => controller.abort(); }, []); return (
Your media + Magent

Make yourself at home.

Something to watch, or something to sort out?

{error ? (

{error}

{" "} Back to sign in
) : !ready ? (

Getting things ready…

) : (
{url ? (

Open Jellyfin

Find your next favourite. Watch movies and TV shows.

Let’s watch
) : (

Open Jellyfin

The watch link hasn’t been set up yet. Please ask an admin to add the public playback URL.

)}

View stats & requests

Check your viewing stats, follow your requests, or make a new one.

Open Magent
)}
); }