From 2ce6fea782553fe283f64a6a8f42e7dd7da31179 Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:27:23 +0200 Subject: [PATCH] fix(bs): server not right --- apps/web/.env.example | 9 +++++---- apps/web/src/lib/utils/mediamtx/server.ts | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/web/.env.example b/apps/web/.env.example index ae709a0..c36beb4 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -23,10 +23,11 @@ MEDIAMTX_API_HQ=http://localhost:9997 NEXT_PUBLIC_MEDIAMTX_INGEST_ROUTE_HQ=localhost:8890 NEXT_PUBLIC_MEDIAMTX_WHIP_ROUTE_HQ=http://localhost:8889 -# commented because we don't have another ingest server as of right now -# NEXT_PUBLIC_MEDIAMTX_URL_ASIA=http://localhost:8991 -# MEDIAMTX_API_ASIA=http://localhost:9999 -# NEXT_PUBLIC_MEDIAMTX_INGEST_ROUTE_ASIA=localhost:8990 +# optional EU mirror +# NEXT_PUBLIC_MEDIAMTX_URL_ETHANDE=https://hls-eu.example.com +# MEDIAMTX_API_ETHANDE=https://mediamtx-api-eu.example.com +# NEXT_PUBLIC_MEDIAMTX_INGEST_ROUTE_ETHANDE=ingest-eu.example.com:8890 +# NEXT_PUBLIC_MEDIAMTX_WHIP_ROUTE_ETHANDE=https://webrtc-eu.example.com # generate with `openssl rand -base64 20` MEDIAMTX_PUBLISH_KEY= diff --git a/apps/web/src/lib/utils/mediamtx/server.ts b/apps/web/src/lib/utils/mediamtx/server.ts index 73033b2..513bcd0 100644 --- a/apps/web/src/lib/utils/mediamtx/server.ts +++ b/apps/web/src/lib/utils/mediamtx/server.ts @@ -5,11 +5,9 @@ export interface MediaMTXEnvs { apiAuthHeader?: string; } -export const MEDIAMTX_SERVER_REGIONS: Record = { - hq: { - apiUrl: process.env.MEDIAMTX_API_HQ!, - apiAuthHeader: getMediamtxApiAuthHeader(), - }, +export const MEDIAMTX_SERVER_REGIONS: Partial> = { + hq: createMediamtxEnvs(process.env.MEDIAMTX_API_HQ), + ethande: createMediamtxEnvs(process.env.MEDIAMTX_API_ETHANDE), }; export function getMediamtxEnvs(region: MediaMTXRegion = 'hq'): MediaMTXEnvs { @@ -31,3 +29,14 @@ function getMediamtxApiAuthHeader() { return `Basic ${Buffer.from(`hctv-api:${apiKey}`).toString('base64')}`; } + +function createMediamtxEnvs(apiUrl?: string): MediaMTXEnvs | undefined { + if (!apiUrl) { + return undefined; + } + + return { + apiUrl, + apiAuthHeader: getMediamtxApiAuthHeader(), + }; +}