From 891610ea7f41ef9b511af3019302880189240ff1 Mon Sep 17 00:00:00 2001 From: Flo2410 Date: Tue, 30 Jan 2024 21:36:53 +0000 Subject: [PATCH] Set user agent in cached-fetch request. This makes the Google search suggestion API return charset=utf-8. --- src/utils/proxy/cached-fetch.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/proxy/cached-fetch.js b/src/utils/proxy/cached-fetch.js index 0ed39562..de837721 100644 --- a/src/utils/proxy/cached-fetch.js +++ b/src/utils/proxy/cached-fetch.js @@ -12,7 +12,11 @@ export default async function cachedFetch(url, duration) { return cached; } - const data = await fetch(url).then((res) => res.json()); + const data = await fetch(url, { + headers: { + "User-Agent": "Mozilla/5.0", + }, + }).then((res) => res.json()); cache.put(url, data, duration * 1000 * 60); return data; }