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

Proxy video thumbnails through selected instance

This commit is contained in:
Cadence Ember 2020-10-18 21:51:09 +13:00
parent 2030f623a0
commit a96d97c9d8
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
9 changed files with 22 additions and 16 deletions

View file

@ -1,14 +1,16 @@
const fetch = require("node-fetch")
const {render} = require("pinski/plugins")
const {getUser} = require("../utils/getuser")
module.exports = [
{
route: "/(?:search|results)", methods: ["GET"], code: async ({url}) => {
route: "/(?:search|results)", methods: ["GET"], code: async ({req, url}) => {
const query = url.searchParams.get("q") || url.searchParams.get("search_query")
const fetchURL = new URL("http://localhost:3000/api/v1/search")
fetchURL.searchParams.set("q", query)
const results = await fetch(fetchURL.toString()).then(res => res.json())
return render(200, "pug/search.pug", {query, results})
const instanceOrigin = getUser(req).getSettingsOrDefaults().instance
return render(200, "pug/search.pug", {query, results, instanceOrigin})
}
}
]