diff --git a/src/front/cobalt.js b/src/front/cobalt.js index 1d1d625e..83cd5c65 100644 --- a/src/front/cobalt.js +++ b/src/front/cobalt.js @@ -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; diff --git a/src/modules/stream/manage.js b/src/modules/stream/manage.js index 827af46c..cc950950 100644 --- a/src/modules/stream/manage.js +++ b/src/modules/stream/manage.js @@ -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) { @@ -46,7 +46,7 @@ export function verifyStream(ip, id, hmac, exp) { if (id.length === 21) { let streamInfo = streamCache.get(id); if (!streamInfo) return { error: 'this stream token does not exist', status: 400 }; - + let ghmac = sha256(`${id},${ip},${streamInfo.service},${exp}`, salt); if (String(hmac) === ghmac && String(exp) === String(streamInfo.exp) && ghmac === String(streamInfo.hmac) && String(ip) === streamInfo.ip && Number(exp) > Math.floor(new Date().getTime())) {