fix: add cookie-aware session establishment for stream AJAX endpoints

Root cause: upstream /ajax/server and /ajax/server/list endpoints require
session cookies set by visiting the watch page. fetchWithMirror() didn't
persist cookies between requests, causing upstream to return 500.

- Extract cookies from set-cookie headers when fetching watch/home page
- Pass cookies with AJAX requests for stream info and server list
- Accept optional slug query param in /api/stream for targeted session
- Both extractors now use cookie-aware axios for session establishment
This commit is contained in:
Shinei Nouzen
2026-08-14 06:59:17 +05:30
parent 320bf0915b
commit 75199d4dcd
3 changed files with 82 additions and 14 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ import { getCache, setCache, TTL } from "../helper/cache.helper.js";
*/
const getStreamInfo = async (req, res, next) => {
try {
const { id } = req.query;
const { id, slug } = req.query;
if (!id) {
return res.status(400).json({ success: false, message: "Link ID is required" });
}
@@ -55,7 +55,7 @@ const getStreamInfo = async (req, res, next) => {
}
let data;
try {
data = await extractStreamInfo(id);
data = await extractStreamInfo(id, slug);
} catch (upstreamError) {
return res.status(502).json({ success: false, message: `Upstream API error: ${upstreamError.message}` });
}