Fix stream endpoint to use configured library path

This commit is contained in:
2025-12-07 23:28:38 +00:00
parent 48bfa048a0
commit 43bcaa88a6

View File

@@ -542,9 +542,19 @@ router.get('/stream.view', authenticateSubsonic, async (req, res) => {
return sendSubsonicError(res, 70, 'Song not found'); return sendSubsonicError(res, 70, 'Song not found');
} }
const filePath = `${process.cwd()}/audio_library/${track.file_path}`; // Use the configured library path from settings
const { loadConfig } = await import('../routes/settings.js');
const config = await loadConfig();
const libraryPath = path.isAbsolute(config.libraryPath)
? config.libraryPath
: path.join(process.cwd(), config.libraryPath);
const filePath = path.join(libraryPath, track.file_path);
console.log(`🎵 Streaming: ${filePath}`);
res.sendFile(filePath); res.sendFile(filePath);
} catch (error) { } catch (error) {
console.error('Error streaming:', error);
sendSubsonicError(res, 0, error.message); sendSubsonicError(res, 0, error.message);
} }
}); });