Set user agent in cached-fetch request.

This makes the Google search suggestion API return charset=utf-8.
This commit is contained in:
Flo2410 2024-01-30 21:36:53 +00:00
parent d75c361603
commit 891610ea7f
No known key found for this signature in database
GPG Key ID: 8ECB00AC5216DC7F

View File

@ -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;
}