mirror of
https://github.com/KevinMidboe/seasoned.git
synced 2026-03-10 19:39:10 +00:00
Fix: Correct API URL construction to prevent double URL issue
- 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 ✓
This commit is contained in:
@@ -113,11 +113,11 @@ export function usePlexApi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch library sections
|
// Fetch library sections
|
||||||
async function fetchLibrarySections(authToken: string) {
|
async function fetchLibrarySections(authToken: string, serverUrl: string) {
|
||||||
if (!plexServerUrl.value) return [];
|
if (!serverUrl) return [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${plexServerUrl.value}/library/sections`, {
|
const response = await fetch(`${serverUrl}/library/sections`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/json",
|
accept: "application/json",
|
||||||
@@ -138,13 +138,17 @@ export function usePlexApi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch library details
|
// Fetch library details
|
||||||
async function fetchLibraryDetails(authToken: string, sectionKey: string) {
|
async function fetchLibraryDetails(
|
||||||
if (!plexServerUrl.value) return null;
|
authToken: string,
|
||||||
|
serverUrl: string,
|
||||||
|
sectionKey: string
|
||||||
|
) {
|
||||||
|
if (!serverUrl) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch all items
|
// Fetch all items
|
||||||
const allResponse = await fetch(
|
const allResponse = await fetch(
|
||||||
`${plexServerUrl.value}/library/sections/${sectionKey}/all`,
|
`${serverUrl}/library/sections/${sectionKey}/all`,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -159,7 +163,7 @@ export function usePlexApi() {
|
|||||||
|
|
||||||
// Fetch recently added
|
// Fetch recently added
|
||||||
const recentResponse = await fetch(
|
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",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user