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.
This commit is contained in:
wukko 2024-12-13 16:01:16 +06:00
parent 5973d70053
commit 3dafdd825a
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -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);