From 017a489b0db0f4944ae26e02b768416a552cc9f5 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Fri, 27 Feb 2026 18:01:38 +0100 Subject: [PATCH] Fix: Correct API URL construction to prevent double URL issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update fetchLibrarySections to accept serverUrl parameter - Was using internal plexServerUrl.value ref - Now accepts explicit serverUrl parameter - Prevents URL doubling when called from PlexSettings - Update fetchLibraryDetails to accept serverUrl parameter - Changed signature: (authToken, serverUrl, sectionKey) - Was: (authToken, sectionKey) using internal ref - Now matches how it's called from loadLibraries composable - Fixes 404 errors from malformed URLs like: http://server.com/library/sectionshttp://server.com/library/sections Library API calls now use correct single URLs ✓ --- src/composables/usePlexApi.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/composables/usePlexApi.ts b/src/composables/usePlexApi.ts index 1402ac2..2a7fec9 100644 --- a/src/composables/usePlexApi.ts +++ b/src/composables/usePlexApi.ts @@ -113,11 +113,11 @@ export function usePlexApi() { } // Fetch library sections - async function fetchLibrarySections(authToken: string) { - if (!plexServerUrl.value) return []; + async function fetchLibrarySections(authToken: string, serverUrl: string) { + if (!serverUrl) return []; try { - const response = await fetch(`${plexServerUrl.value}/library/sections`, { + const response = await fetch(`${serverUrl}/library/sections`, { method: "GET", headers: { accept: "application/json", @@ -138,13 +138,17 @@ export function usePlexApi() { } // Fetch library details - async function fetchLibraryDetails(authToken: string, sectionKey: string) { - if (!plexServerUrl.value) return null; + async function fetchLibraryDetails( + authToken: string, + serverUrl: string, + sectionKey: string + ) { + if (!serverUrl) return null; try { // Fetch all items const allResponse = await fetch( - `${plexServerUrl.value}/library/sections/${sectionKey}/all`, + `${serverUrl}/library/sections/${sectionKey}/all`, { method: "GET", headers: { @@ -159,7 +163,7 @@ export function usePlexApi() { // Fetch recently added const recentResponse = await fetch( - `${plexServerUrl.value}/library/sections/${sectionKey}/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=5`, + `${serverUrl}/library/sections/${sectionKey}/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=5`, { method: "GET", headers: {