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.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 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 SABNZBD_URL = process.env.SABNZBD_URL;
|
|
const SABNZBD_API_KEY = process.env.SABNZBD_API_KEY;
|
|
|
|
router.use(requireAuth);
|
|
|
|
// Get current queue
|
|
router.get('/queue', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SABNZBD_URL}/api`, {
|
|
params: {
|
|
mode: 'queue',
|
|
apikey: SABNZBD_API_KEY,
|
|
output: 'json'
|
|
}
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch SABnzbd queue', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
// Get history
|
|
router.get('/history', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SABNZBD_URL}/api`, {
|
|
params: {
|
|
mode: 'history',
|
|
apikey: SABNZBD_API_KEY,
|
|
output: 'json',
|
|
limit: req.query.limit || 50
|
|
}
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch SABnzbd history', details: sanitizeError(error) });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|