From b2c94ea62351fdad7b316eb04b4bcb9ee79d5200 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 24 Dec 2025 23:26:36 -0800 Subject: [PATCH] Update hardcoded Cloudflare Stream UID to a constant and remove dynamic HLS URL updates --- packages/web/src/routes/$username.tsx | 18 ++++++------------ packages/web/src/routes/api/check-hls.ts | 11 +++++------ packages/web/wrangler.jsonc | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/web/src/routes/$username.tsx b/packages/web/src/routes/$username.tsx index fcd920b4..61f641f9 100644 --- a/packages/web/src/routes/$username.tsx +++ b/packages/web/src/routes/$username.tsx @@ -22,8 +22,9 @@ export const Route = createFileRoute("/$username")({ component: StreamPage, }) -// Default Cloudflare Stream HLS URL (will be overridden by API) -const DEFAULT_HLS_URL = "https://customer-xctsztqzu046isdc.cloudflarestream.com/cd56ef73791c628c252cd290ee710275/manifest/video.m3u8" +// Cloudflare Live Input UID (constant - automatically shows current live stream) +const LIVE_INPUT_UID = "bb7858eafc85de6c92963f3817477b5d" +const HLS_URL = `https://customer-xctsztqzu046isdc.cloudflarestream.com/${LIVE_INPUT_UID}/manifest/video.m3u8` const READY_PULSE_MS = 1200 // Hardcoded user for nikiv (hls_url will be updated from API) @@ -58,7 +59,6 @@ function StreamPage() { const [error, setError] = useState(null) const [playerReady, setPlayerReady] = useState(false) const [hlsLive, setHlsLive] = useState(null) - const [hlsUrl, setHlsUrl] = useState(DEFAULT_HLS_URL) const [isConnecting, setIsConnecting] = useState(false) const [nowPlaying, setNowPlaying] = useState( null, @@ -78,9 +78,9 @@ function StreamPage() { useEffect(() => { let isActive = true - // Special handling for nikiv - hardcoded stream with dynamic HLS URL + // Special handling for nikiv - hardcoded stream with constant Live Input URL if (username === "nikiv") { - setData(makeNikivData(hlsUrl)) + setData(makeNikivData(HLS_URL)) setLoading(false) return () => { isActive = false @@ -197,12 +197,6 @@ function StreamPage() { const apiData = await res.json() - // Update HLS URL if returned from API - if (apiData.hlsUrl && apiData.hlsUrl !== hlsUrl) { - setHlsUrl(apiData.hlsUrl) - setData(makeNikivData(apiData.hlsUrl)) - } - if (apiData.isLive) { // Stream is live - set connecting state if first time if (!hasConnectedOnce.current) { @@ -232,7 +226,7 @@ function StreamPage() { isActive = false clearInterval(interval) } - }, [username, hlsUrl]) + }, [username]) // For non-nikiv users, use direct HLS check useEffect(() => { diff --git a/packages/web/src/routes/api/check-hls.ts b/packages/web/src/routes/api/check-hls.ts index c823910a..bc33e308 100644 --- a/packages/web/src/routes/api/check-hls.ts +++ b/packages/web/src/routes/api/check-hls.ts @@ -1,4 +1,4 @@ -import { createFileRoute, getServerContext } from "@tanstack/react-router" +import { createFileRoute } from "@tanstack/react-router" const json = (data: unknown, status = 200) => new Response(JSON.stringify(data), { @@ -6,13 +6,12 @@ const json = (data: unknown, status = 200) => headers: { "content-type": "application/json" }, }) -// Default video ID (fallback) -const DEFAULT_VIDEO_ID = "cd56ef73791c628c252cd290ee710275" +// Cloudflare Live Input UID (constant - automatically shows current live stream) +const LIVE_INPUT_UID = "bb7858eafc85de6c92963f3817477b5d" +const HLS_URL = `https://customer-xctsztqzu046isdc.cloudflarestream.com/${LIVE_INPUT_UID}/manifest/video.m3u8` function getHlsUrl(): string { - const ctx = (getServerContext as () => { cloudflare?: { env?: Record } } | null)() - const videoId = ctx?.cloudflare?.env?.CLOUDFLARE_STREAM_NIKIV_VIDEO_ID || DEFAULT_VIDEO_ID - return `https://customer-xctsztqzu046isdc.cloudflarestream.com/${videoId}/manifest/video.m3u8` + return HLS_URL } function isHlsPlaylistLive(manifest: string): boolean { diff --git a/packages/web/wrangler.jsonc b/packages/web/wrangler.jsonc index 192113d7..c6b1d0ed 100644 --- a/packages/web/wrangler.jsonc +++ b/packages/web/wrangler.jsonc @@ -30,7 +30,7 @@ */ "vars": { "APP_BASE_URL": "https://linsa.io", - "CLOUDFLARE_STREAM_NIKIV_VIDEO_ID": "cd56ef73791c628c252cd290ee710275" + "CLOUDFLARE_LIVE_INPUT_UID": "bb7858eafc85de6c92963f3817477b5d" }, /** * Note: Use secrets to store sensitive data.