1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-05-26 12:32:25 +00:00

Proxy captions via new /proxy route

We can add more authorized paths to authorizedPaths if we need
more resources to be pulled from the NewLeaf/Invidious backend
on the same domain.

This route forwards to the client a few headers like Bibliogram
ea7cd5d5/item/src/site/api/proxy.js (L28-29)
so we can also use this route to possibly proxy videos in the
future.

We are strict about the url parameter not overriding the
NewLeaf/Invidious backend (instanceOrigin) by ensuring
fetchURL has instanceOrigin as prefix.
This commit is contained in:
Lomanic 2021-05-22 02:32:43 +02:00 committed by Cadence Ember
parent db49bb38b0
commit eb111a44c4
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
3 changed files with 32 additions and 27 deletions

View file

@ -174,6 +174,11 @@ module.exports = [
// rewrite description
video.descriptionHtml = converters.rewriteVideoDescription(video.descriptionHtml, id)
// rewrite captions urls so they are served on the same domain via the /proxy route
for (const caption of video.captions) {
caption.url = `/proxy?${new URLSearchParams({"url": caption.url})}`
}
return render(200, "pug/video.pug", {
url, video, formats, subscribed, instanceOrigin, mediaFragment, autoplay, continuous,
sessionWatched, sessionWatchedNext