diff --git a/.env.example b/.env.example index ec7ab201..7e29b8e5 100644 --- a/.env.example +++ b/.env.example @@ -80,8 +80,10 @@ CACHE_TRANSCODE_MINUTES=60 SUBSONIC_URL=http://localhost:4533 # ===== JELLYFIN CONFIGURATION ===== -# Server URL (required if using Jellyfin backend) -JELLYFIN_URL=http://localhost:8096 +# Server URL (required if using Jellyfin backend). +# From Docker, localhost is the Allstarr container. Use host.docker.internal for +# Jellyfin on the Docker host, or the Jellyfin service name on a shared network. +JELLYFIN_URL=http://host.docker.internal:8096 # API key for SERVER-SIDE operations only (get from Jellyfin Dashboard > API Keys) # This is used by Allstarr to query Jellyfin's library on behalf of the server diff --git a/README.md b/README.md index 55c82ab7..53a40570 100644 --- a/README.md +++ b/README.md @@ -200,8 +200,8 @@ Choose your preferred provider via the `MUSIC_SERVICE` environment variable. Add # Backend selection BACKEND_TYPE=Jellyfin - # Jellyfin server URL - JELLYFIN_URL=http://localhost:8096 + # Jellyfin on the Docker host (use its service name on a shared Docker network) + JELLYFIN_URL=http://host.docker.internal:8096 # API key (get from Jellyfin Dashboard > API Keys) JELLYFIN_API_KEY=your-api-key-here @@ -213,6 +213,10 @@ Choose your preferred provider via the `MUSIC_SERVICE` environment variable. Add JELLYFIN_LIBRARY_ID= ``` + `localhost` inside the Allstarr container points to Allstarr itself, not to + Jellyfin. The Compose file maps `host.docker.internal` on Linux, macOS, and + Windows for a Jellyfin server running on the Docker host. + ```bash # Path where downloaded songs will be stored DOWNLOAD_PATH=./downloads diff --git a/allstarr.Tests/AdminAuthControllerTests.cs b/allstarr.Tests/AdminAuthControllerTests.cs index 233b3393..27a1abee 100644 --- a/allstarr.Tests/AdminAuthControllerTests.cs +++ b/allstarr.Tests/AdminAuthControllerTests.cs @@ -63,7 +63,9 @@ public class AdminAuthControllerTests Assert.NotNull(capturedRequest); Assert.Equal(HttpMethod.Post, capturedRequest!.Method); Assert.Equal("http://jellyfin.local/Users/AuthenticateByName", capturedRequest.RequestUri?.ToString()); - Assert.Contains("X-Emby-Authorization", capturedRequest.Headers.Select(h => h.Key)); + Assert.StartsWith("MediaBrowser Client=\"AllstarrAdmin\"", + capturedRequest.Headers.GetValues("Authorization").Single()); + Assert.False(capturedRequest.Headers.Contains("X-Emby-Authorization")); Assert.NotNull(capturedBody); Assert.Contains("\"Username\":\"josh\"", capturedBody!); diff --git a/allstarr/AppVersion.cs b/allstarr/AppVersion.cs index 477b2304..206d9ae5 100644 --- a/allstarr/AppVersion.cs +++ b/allstarr/AppVersion.cs @@ -9,5 +9,5 @@ public static class AppVersion /// /// Current application version. /// - public const string Version = "2.0.2"; + public const string Version = "2.0.3"; } diff --git a/allstarr/Controllers/AdminAuthController.cs b/allstarr/Controllers/AdminAuthController.cs index 39363801..5a8a4d2e 100644 --- a/allstarr/Controllers/AdminAuthController.cs +++ b/allstarr/Controllers/AdminAuthController.cs @@ -64,7 +64,7 @@ public class AdminAuthController : ControllerBase { Content = new StringContent(loginJson, Encoding.UTF8, "application/json") }; - httpRequest.Headers.TryAddWithoutValidation("X-Emby-Authorization", authHeader); + httpRequest.Headers.TryAddWithoutValidation("Authorization", authHeader); using var response = await _httpClient.SendAsync(httpRequest); diff --git a/docker-compose.yml b/docker-compose.yml index fe83c7e1..68df1d7c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,6 +66,9 @@ services: start_period: 40s networks: - allstarr-network + extra_hosts: + # Lets Linux containers reach Jellyfin running on the Docker host. + - "host.docker.internal:host-gateway" environment: - ASPNETCORE_ENVIRONMENT=Production # Backend type: Subsonic or Jellyfin (default: Subsonic) @@ -101,7 +104,7 @@ services: - Subsonic__PlaylistsDirectory=${PLAYLISTS_DIRECTORY:-playlists} # ===== JELLYFIN BACKEND ===== - - Jellyfin__Url=${JELLYFIN_URL:-http://localhost:8096} + - Jellyfin__Url=${JELLYFIN_URL:-http://host.docker.internal:8096} - Jellyfin__ApiKey=${JELLYFIN_API_KEY:-} - Jellyfin__UserId=${JELLYFIN_USER_ID:-} - Jellyfin__LibraryId=${JELLYFIN_LIBRARY_ID:-}