From 3dafdd825a8d98983103f0275cf4199bbd6af01b Mon Sep 17 00:00:00 2001 From: wukko Date: Fri, 13 Dec 2024 16:01:16 +0600 Subject: [PATCH] api/types/proxy: use default dispatcher instead of a global one this function never gets anything but internal streams, so global proxy (`API_EXTERNAL_PROXY`) is only causing issues here. this commit fixes an issue of cobalt attempting to proxy internal streams, and failing spectacularly. --- api/src/stream/types.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/stream/types.js b/api/src/stream/types.js index 98c3b04e..0a4e2d47 100644 --- a/api/src/stream/types.js +++ b/api/src/stream/types.js @@ -1,4 +1,4 @@ -import { request } from "undici"; +import { Agent, request } from "undici"; import ffmpeg from "ffmpeg-static"; import { spawn } from "child_process"; import { create as contentDisposition } from "content-disposition-header"; @@ -60,6 +60,8 @@ const getCommand = (args) => { return [ffmpeg, args] } +const defaultAgent = new Agent(); + const proxy = async (streamInfo, res) => { const abortController = new AbortController(); const shutdown = () => ( @@ -78,7 +80,8 @@ const proxy = async (streamInfo, res) => { Range: streamInfo.range }, signal: abortController.signal, - maxRedirections: 16 + maxRedirections: 16, + dispatcher: defaultAgent, }); res.status(statusCode);