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:
fluofoxxo 2023-04-12 19:40:13 -04:00
parent b4eddd06fe
commit b62627058e
2 changed files with 4 additions and 3 deletions

View File

@ -366,7 +366,8 @@ async function download(url) {
break;
case "stream":
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();
if (jp.status === "continue") {
changeDownloadButton(2, '>>>'); window.location.href = j.url;

View File

@ -38,7 +38,7 @@ export function createStream(obj) {
exp = streamInfo.exp;
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) {