mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-16 10:18:28 +00:00
Fix local development download issues
Fixes issues downloading files retrieved from a local instance of cobalt. The fix involves changing the URL that createStream() in modules/stream/manage.js returns to just a slug, and having the frontend find the origin to prepend to the slug for its API call.
This commit is contained in:
parent
b4eddd06fe
commit
b62627058e
@ -366,7 +366,8 @@ async function download(url) {
|
|||||||
break;
|
break;
|
||||||
case "stream":
|
case "stream":
|
||||||
changeDownloadButton(2, '?..')
|
changeDownloadButton(2, '?..')
|
||||||
fetch(`${j.url}&p=1`).then(async (res) => {
|
const streamUrl = location.origin + j.url;
|
||||||
|
fetch(`${streamUrl}&p=1`).then(async (res) => {
|
||||||
let jp = await res.json();
|
let jp = await res.json();
|
||||||
if (jp.status === "continue") {
|
if (jp.status === "continue") {
|
||||||
changeDownloadButton(2, '>>>'); window.location.href = j.url;
|
changeDownloadButton(2, '>>>'); window.location.href = j.url;
|
||||||
|
@ -38,7 +38,7 @@ export function createStream(obj) {
|
|||||||
exp = streamInfo.exp;
|
exp = streamInfo.exp;
|
||||||
ghmac = streamInfo.hmac;
|
ghmac = streamInfo.hmac;
|
||||||
}
|
}
|
||||||
return `${process.env.selfURL}api/stream?t=${streamID}&e=${exp}&h=${ghmac}`;
|
return `/api/stream?t=${streamID}&e=${exp}&h=${ghmac}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verifyStream(ip, id, hmac, exp) {
|
export function verifyStream(ip, id, hmac, exp) {
|
||||||
@ -46,7 +46,7 @@ export function verifyStream(ip, id, hmac, exp) {
|
|||||||
if (id.length === 21) {
|
if (id.length === 21) {
|
||||||
let streamInfo = streamCache.get(id);
|
let streamInfo = streamCache.get(id);
|
||||||
if (!streamInfo) return { error: 'this stream token does not exist', status: 400 };
|
if (!streamInfo) return { error: 'this stream token does not exist', status: 400 };
|
||||||
|
|
||||||
let ghmac = sha256(`${id},${ip},${streamInfo.service},${exp}`, salt);
|
let ghmac = sha256(`${id},${ip},${streamInfo.service},${exp}`, salt);
|
||||||
if (String(hmac) === ghmac && String(exp) === String(streamInfo.exp) && ghmac === String(streamInfo.hmac)
|
if (String(hmac) === ghmac && String(exp) === String(streamInfo.exp) && ghmac === String(streamInfo.hmac)
|
||||||
&& String(ip) === streamInfo.ip && Number(exp) > Math.floor(new Date().getTime())) {
|
&& String(ip) === streamInfo.ip && Number(exp) > Math.floor(new Date().getTime())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user