Prevent flooding logs when no logo is available

pull/9194/head
zomars 2023-05-29 19:44:20 -07:00
parent 1065108a42
commit 0ed5ce229b
1 changed files with 11 additions and 6 deletions

View File

@ -79,10 +79,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const filteredLogo = parsedQuery?.icon ? appIconLogo : appLogo;
const response = await fetch(filteredLogo);
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
res.setHeader("Content-Type", response.headers.get("content-type") as string);
res.setHeader("Cache-Control", "s-maxage=86400");
res.send(buffer);
try {
const response = await fetch(filteredLogo);
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
res.setHeader("Content-Type", response.headers.get("content-type") as string);
res.setHeader("Cache-Control", "s-maxage=86400");
res.send(buffer);
} catch (error) {
res.statusCode = 404;
res.json({ error: "Failed fetching logo" });
}
}