All checks were successful
Build and Push Docker Image / build (push) Successful in 39s
#1 Session cookie: add secure (production-only) and sameSite=strict to prevent transmission over HTTP and cross-site request abuse. #2 Remove Emby AccessToken from cookie payload — it was stored in the browser cookie but is never needed client-side; reduces blast radius if cookie is ever exposed. #3 Add requireAuth middleware to all proxy routes (/api/emby, /api/sabnzbd, /api/sonarr, /api/radarr) — previously unauthenticated, now require a valid emby_user session cookie. #4 Remove open CORS wildcard (cors() with no options). The frontend is served from the same origin so no CORS headers are required. Also update clearCookie() to include matching cookie options.
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
const express = require('express');
|
|
const axios = require('axios');
|
|
const router = express.Router();
|
|
const requireAuth = require('../middleware/requireAuth');
|
|
|
|
const SONARR_URL = process.env.SONARR_URL;
|
|
const SONARR_API_KEY = process.env.SONARR_API_KEY;
|
|
|
|
router.use(requireAuth);
|
|
|
|
// Get queue
|
|
router.get('/queue', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SONARR_URL}/api/v3/queue`, {
|
|
headers: { 'X-Api-Key': SONARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch Sonarr queue', details: error.message });
|
|
}
|
|
});
|
|
|
|
// Get history
|
|
router.get('/history', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SONARR_URL}/api/v3/history`, {
|
|
headers: { 'X-Api-Key': SONARR_API_KEY },
|
|
params: { pageSize: req.query.pageSize || 50 }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch Sonarr history', details: error.message });
|
|
}
|
|
});
|
|
|
|
// Get series details
|
|
router.get('/series/:id', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SONARR_URL}/api/v3/series/${req.params.id}`, {
|
|
headers: { 'X-Api-Key': SONARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch series details', details: error.message });
|
|
}
|
|
});
|
|
|
|
// Get all series with tags
|
|
router.get('/series', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SONARR_URL}/api/v3/series`, {
|
|
headers: { 'X-Api-Key': SONARR_API_KEY }
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch series', details: error.message });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|