Added server/utils/sanitizeError.js which redacts: - ?apikey= query parameters (SABnzbd passes key in URL) - ?token= query parameters - X-Api-Key / X-MediaBrowser-Token / X-Emby-Authorization header values if they appear in the error message string Applied to all catch blocks in emby.js, sabnzbd.js, sonarr.js, radarr.js, and dashboard.js. Internal error.message still logged server-side (unredacted) for debugging.
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
const express = require('express');
|
|
const axios = require('axios');
|
|
const router = express.Router();
|
|
const requireAuth = require('../middleware/requireAuth');
|
|
const sanitizeError = require('../utils/sanitizeError');
|
|
|
|
const RADARR_URL = process.env.RADARR_URL;
|
|
const RADARR_API_KEY = process.env.RADARR_API_KEY;
|
|
|
|
router.use(requireAuth);
|
|
|
|
// Get queue
|
|
router.get('/queue', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${RADARR_URL}/api/v3/queue`, {
|
|
headers: { 'X-Api-Key': RADARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch Radarr queue', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
// Get history
|
|
router.get('/history', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${RADARR_URL}/api/v3/history`, {
|
|
headers: { 'X-Api-Key': RADARR_API_KEY },
|
|
params: { pageSize: req.query.pageSize || 50 }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch Radarr history', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
// Get movie details
|
|
router.get('/movies/:id', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${RADARR_URL}/api/v3/movie/${req.params.id}`, {
|
|
headers: { 'X-Api-Key': RADARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch movie details', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
// Get all movies with tags
|
|
router.get('/movies', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${RADARR_URL}/api/v3/movie`, {
|
|
headers: { 'X-Api-Key': RADARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch movies', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|