From 0da13ac0e60c4fc7cbdbb559fd50e00346d84758 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 1 Jan 2021 17:15:02 +1300 Subject: [PATCH] Use preferred instance for search --- api/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/search.js b/api/search.js index 0d9dc23..f16d825 100644 --- a/api/search.js +++ b/api/search.js @@ -6,10 +6,10 @@ module.exports = [ { 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") + const instanceOrigin = getUser(req).getSettingsOrDefaults().instance + const fetchURL = new URL(`${instanceOrigin}/api/v1/search`) fetchURL.searchParams.set("q", query) const results = await fetch(fetchURL.toString()).then(res => res.json()) - const instanceOrigin = getUser(req).getSettingsOrDefaults().instance return render(200, "pug/search.pug", {query, results, instanceOrigin}) } }