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:
parent
2030f623a0
commit
a96d97c9d8
9 changed files with 22 additions and 16 deletions
|
|
@ -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})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue