From e46c61e026c556c7222ca551f3a41a0899c810e6 Mon Sep 17 00:00:00 2001 From: ashe Date: Mon, 9 Mar 2026 22:08:28 -0400 Subject: [PATCH] Remote URL hardcoding compatibility (#1810) * Remote URL compatibility --------- Co-authored-by: jeffvli --- Dockerfile | 2 +- README.md | 7 +++++-- docker-compose.yaml | 1 + settings.js.template | 1 + src/preload/index.d.ts | 1 + src/preload/local-settings.ts | 1 + src/renderer/features/login/routes/login-route.tsx | 8 ++++++++ src/renderer/global.d.ts | 1 + 8 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd1b86940..d6da47020 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ COPY --chown=nginx:nginx --from=builder /app/out/web /usr/share/nginx/html COPY ./settings.js.template /etc/nginx/templates/settings.js.template COPY ng.conf.template /etc/nginx/templates/default.conf.template -ENV SERVER_LOCK=false SERVER_NAME="" SERVER_TYPE="" SERVER_URL="" +ENV SERVER_LOCK=false SERVER_NAME="" SERVER_TYPE="" SERVER_URL="" REMOTE_URL="" ENV LEGACY_AUTHENTICATION="" ANALYTICS_DISABLED="" PUBLIC_PATH="/" EXPOSE 9180 diff --git a/README.md b/README.md index e12f4753e..ec7d26cd8 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ services: - SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled - SERVER_TYPE=jellyfin # the allowed types are: jellyfin, navidrome, subsonic. These values are case insensitive - SERVER_URL= # http://address:port or https://address:port + = REMOTE_URL= # http://address or https://address - LEGACY_AUTHENTICATION=false # When SERVER_LOCK is true, sets the legacy (plaintext) authentication flag for Subsonic/OpenSubsonic servers - ANALYTICS_DISABLED=true # Set to true to disable Umami analytics tracking ports: @@ -134,9 +135,11 @@ services: 4. _Optional_ - To hard code the server url, pass the following environment variables: `SERVER_NAME`, `SERVER_TYPE` (one of `jellyfin` or `navidrome` or `subsonic`), `SERVER_URL`. To prevent users from changing these settings, pass `SERVER_LOCK=true`. This can only be set if all three of the previous values are set. When `SERVER_LOCK=true`, you can also set `LEGACY_AUTHENTICATION=true` or `LEGACY_AUTHENTICATION=false` to configure the legacy authentication flag for the server (only applicable for Subsonic/OpenSubsonic servers). -5. _Optional_ - To disable Umami analytics tracking in the Docker/web version, set the environment variable `ANALYTICS_DISABLED=true`. When enabled, the analytics script will not be loaded and all tracking will be disabled. +5. _Optional_ - If your server uses a separate public-facing URL than what integrating applications use internally to communicate with your server, such as a separate Navidrome `ShareURL`, set `REMOTE_URL` to said public-facing URL. + +6. _Optional_ - To disable Umami analytics tracking in the Docker/web version, set the environment variable `ANALYTICS_DISABLED=true`. When enabled, the analytics script will not be loaded and all tracking will be disabled. -6. _Optional_ - App settings (theme, language, sidebar options, etc.) can be overridden with environment variables on first run. The variables use the `FS_` prefix (e.g. `FS_GENERAL_THEME=defaultDark`, `FS_GENERAL_LANGUAGE=de`). See [the settings environment variable documentation](docs/ENV_SETTINGS.md) for the full list. +7. _Optional_ - App settings (theme, language, sidebar options, etc.) can be overridden with environment variables on first run. The variables use the `FS_` prefix (e.g. `FS_GENERAL_THEME=defaultDark`, `FS_GENERAL_LANGUAGE=de`). See [the settings environment variable documentation](docs/ENV_SETTINGS.md) for the full list. ## FAQ diff --git a/docker-compose.yaml b/docker-compose.yaml index 1ffc78d66..2e2d9c6d5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,6 +8,7 @@ services: - SERVER_LOCK=false # When true AND name/type/url are set, only username/password can be toggled - SERVER_TYPE=jellyfin # the allowed types are: jellyfin, navidrome, subsonic. These values are case insensitive - SERVER_URL=http://localhost:8096 # http://address:port or https://address:port + # - REMOTE_URL=http://share.localhost # Used for compatibility with external functionality, such as custom sharing URLs on Navidrome - LEGACY_AUTHENTICATION=false # When SERVER_LOCK is true, sets the legacyauth flag for server authentication (true or false) - ANALYTICS_DISABLED=false # Set to true to disable Umami analytics tracking ports: diff --git a/settings.js.template b/settings.js.template index af9642954..f84b57f81 100644 --- a/settings.js.template +++ b/settings.js.template @@ -1,6 +1,7 @@ "use strict"; window.SERVER_URL = "${SERVER_URL}"; +window.REMOTE_URL = "${REMOTE_URL}"; window.SERVER_NAME = "${SERVER_NAME}"; window.SERVER_TYPE = "${SERVER_TYPE}"; window.SERVER_LOCK = "${SERVER_LOCK}"; diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index a3abebf4f..70f7d3b13 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -8,6 +8,7 @@ declare global { electron: ElectronAPI; LEGACY_AUTHENTICATION?: boolean; queryLocalFonts?: () => Promise; + REMOTE_URL?: string; SERVER_LOCK?: boolean; SERVER_NAME?: string; SERVER_TYPE?: ServerType; diff --git a/src/preload/local-settings.ts b/src/preload/local-settings.ts index 572a19ea7..6729d9a68 100644 --- a/src/preload/local-settings.ts +++ b/src/preload/local-settings.ts @@ -74,6 +74,7 @@ const env = { SERVER_TYPE !== null ? process.env.LEGACY_AUTHENTICATION?.toLocaleLowerCase() === 'true' : false, + REMOTE_URL: process.env.REMOTE_URL ?? '', SERVER_LOCK: SERVER_TYPE !== null ? process.env.SERVER_LOCK?.toLocaleLowerCase() === 'true' : false, SERVER_NAME: process.env.SERVER_NAME ?? '', diff --git a/src/renderer/features/login/routes/login-route.tsx b/src/renderer/features/login/routes/login-route.tsx index 20a9cda2f..55a90ae60 100644 --- a/src/renderer/features/login/routes/login-route.tsx +++ b/src/renderer/features/login/routes/login-route.tsx @@ -65,6 +65,7 @@ const LoginRoute = () => { const serverType = window.SERVER_TYPE ? toServerType(window.SERVER_TYPE) : null; const serverName = window.SERVER_NAME || ''; const serverUrl = window.SERVER_URL || ''; + const remoteUrl = window.REMOTE_URL || ''; const legacyAuth = serverLock && isLegacyAuth(); const config = [ @@ -88,6 +89,11 @@ const LoginRoute = () => { key: 'SERVER_URL', value: serverUrl, }, + { + isValid: remoteUrl !== '', + key: 'REMOTE_URL', + value: remoteUrl, + }, ]; const form = useForm({ @@ -150,6 +156,7 @@ const LoginRoute = () => { } const normalizedUrl = normalizeUrl(serverUrl); + const normalizedRemoteURL = normalizeUrl(remoteUrl); const existingServer = serverLock && Object.values(serverList).find((s) => normalizeUrl(s.url) === normalizedUrl); @@ -159,6 +166,7 @@ const LoginRoute = () => { id: nanoid(), isAdmin: data.isAdmin, name: serverName, + remoteUrl: normalizedRemoteURL, type: serverType as ServerType, url: normalizedUrl, userId: data.userId, diff --git a/src/renderer/global.d.ts b/src/renderer/global.d.ts index 864f0c063..b1a24fc73 100644 --- a/src/renderer/global.d.ts +++ b/src/renderer/global.d.ts @@ -74,6 +74,7 @@ declare global { FS_PLAYBACK_TRANSCODE_ENABLED?: string; FS_PLAYBACK_WEB_AUDIO?: string; LEGACY_AUTHENTICATION?: boolean | string; + REMOTE_URL?: string; SERVER_LOCK?: boolean | string; SERVER_NAME?: string; SERVER_TYPE?: string;