mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
fix: detect upstream API errors in stream endpoint to prevent null URL responses
- Added upstream error detection in streamInfo.extractor.js (status >= 400) - Added non-JSON error string detection from upstream API - Updated streamInfo.controller.js to return HTTP 502 for upstream failures - Fixes /api/stream returning null URL when upstream returns error responses
This commit is contained in:
@@ -53,7 +53,12 @@ const getStreamInfo = async (req, res, next) => {
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractStreamInfo(id);
|
||||
let data;
|
||||
try {
|
||||
data = await extractStreamInfo(id);
|
||||
} catch (upstreamError) {
|
||||
return res.status(502).json({ success: false, message: `Upstream API error: ${upstreamError.message}` });
|
||||
}
|
||||
if (!data.url) {
|
||||
return res.status(404).json({ success: false, message: "Stream URL not found for this link ID", results: data });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user