best way to save what you love
Svelte collaborationdownloaderinstagramjavascriptmusicredditsocial-mediasoundcloudsveltetiktoktwittertypescriptvideovimeovkwebappyoutubeyoutube-downloader
api/proxy: add support for proxying range requests
dumbmoron2f63f6bab758
diff --git a/api/src/core/api.js b/api/src/core/api.jsindex 9632d588..37c33bd9 100644--- a/api/src/core/api.js+++ b/api/src/core/api.js@@ -243,6 +243,11 @@ export const runAPI = (express, app, __dirname) => {if (!streamInfo?.service) {return res.status(streamInfo.status).end();}++ if (streamInfo.type === 'proxy') {+ streamInfo.range = req.headers['range'];+ }+return stream(res, streamInfo);})diff --git a/api/src/stream/types.js b/api/src/stream/types.jsindex b08c2b05..0f2d0405 100644--- a/api/src/stream/types.js+++ b/api/src/stream/types.js@@ -52,16 +52,21 @@ const proxy = async (streamInfo, res) => {filename = `${streamInfo.filename}.${streamInfo.audioFormat}`}- res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");+ res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');res.setHeader('Content-disposition', contentDisposition(filename));- const { body: stream, headers } = await request(streamInfo.urls, {- headers: getHeaders(streamInfo.service),+ const { body: stream, headers, statusCode } = await request(streamInfo.urls, {+ headers: {+ ...getHeaders(streamInfo.service),+ Range: streamInfo.range+ },signal: abortController.signal,maxRedirections: 16});- for (const headerName of ['content-type', 'content-length']) {+ res.status(statusCode);++ for (const headerName of ['accept-ranges', 'content-type', 'content-length']) {if (headers[headerName]) {res.setHeader(headerName, headers[headerName]);}