taevas.xyz/api/infos/website/umami.ts
Taevas 9818adb12d
Use custom headers to possibly bypass Anubis & co
As recommended by the kind Kio!
(so now most requests use a custom user-agent)
2025-04-17 13:38:00 +02:00

22 lines
870 B
TypeScript

import { headers, parseJson, type Handler } from "../..";
import type { UmamiInfo } from "#Infos/Website/Umami.tsx";
import { db, getToken } from "../../../database.ts";
export const umami: Handler = async () => {
const token = await getToken(db, "umami");
const api_server = "https://visitors.taevas.xyz/api";
const website_id = "f196d626-e609-4841-9a80-0dc60f523ed5";
const now = new Date();
const sevendaysago = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
// Not using the package directly because of serious issues I consider it to have
const umami = await parseJson(await fetch(`${api_server}/websites/${website_id}/stats?startAt=${Number(sevendaysago)}&endAt=${Number(now)}`, {
headers: {
...headers,
"Authorization": `Bearer ${token?.access_token}`
},
})) as UmamiInfo;
return Response.json(umami, {status: 200});
};