Provides Mux CDN origin constants and playback URL utilities in a server-safe (non-`'use client'`) module, enabling both server-side and client-side code to import Mux configuration without triggering Next.js client-reference poisoning. ## Key Components | Export | Type | Description | |---|---|---| | `MUX_STREAM_ORIGIN` | `const string` | Base URL for Mux HLS playback and MP4 renditions (`https://stream.mux.com`) | | `MUX_IMAGE_ORIGIN` | `const string` | Base URL for Mux server-generated thumbnails (`https://image.mux.com`) | | `MuxMaxResolution` | `type` | Union of valid Mux `max_resolution` modifier values: `'720p' \| '1080p' \| '1440p' \| '2160p'` | | `toMuxPreviewUrl` | `function` | Appends a `max_resolution` query param to Mux HLS URLs for bandwidth-capped preview players | ## Usage Example ```typescript import { MUX_STREAM_ORIGIN, MUX_IMAGE_ORIGIN, toMuxPreviewUrl } from './mux-origins' // Server-side hostname comparison (safe — no client stubs) const streamHost = new URL(MUX_STREAM_ORIGIN).hostname // 'stream.mux.com' // Cap renditions for a small hover-card preview player const rawUrl = 'https://stream.mux.com/abc123.m3u8' const previewUrl = toMuxPreviewUrl(rawUrl, '720p') // → 'https://stream.mux.com/abc123.m3u8?max_resolution=720p' // Pass-through cases (no modification) toMuxPreviewUrl('https://example.supabase.co/clip.mp4') // non-Mux host toMuxPreviewUrl('https://stream.mux.com/abc123.mp4') // non-.m3u8 path toMuxPreviewUrl('https://stream.mux.com/abc123.m3u8?token=xyz') // signed URL ``` ## Pass-Through Conditions `toMuxPreviewUrl` returns the original URL unchanged when: - Host is not `stream.mux.com` (e.g. Supabase MP4s, YouTube) - Path does not end in `.m3u8` (e.g. MP4 renditions) - URL already contains a `?token=` param (Mux prohibits loose modifiers alongside JWT tokens) - URL string is unparseable ## Notes - **Server safety:** Intentionally omits `'use client'` so server modules (webhook handlers, Next.js middleware, `lib/config/mux-config.ts`) can import without crashing at Vercel build time. Re-exported from `use-video-warmup.ts` for backward compatibility. - **Safari compatibility:** The `max_resolution` param works at the HLS manifest level, which is the only effective rendition cap on Safari's native HLS player where `hls.js` is unavailable. **Source:** [`mux-origins.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/mux-origins.ts)