mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
The tracker posts to `${data-host-url}${collect path}`, and the collect
path is compiled into the operator's Umami build: /api/send by default,
anything else when the instance sets COLLECT_API_ENDPOINT. The tag
pointed data-host-url at the app origin and the proxy listened only on
/api/send, so a renamed endpoint sent every page view and event to an
app path that does not exist and got a full 404 page back each time.
Point data-host-url at /api/monitoring/umami and answer every path under
it with one proxy route. The route reads the collect path from the
configured tracker (cached for an hour), forwards only that path to the
Umami host, and answers anything else, or an unreadable tracker, with an
empty response. The admin test event posts to the same learnt path. The
send-URL resolver lives in one module instead of two copies.
20 lines
966 B
TypeScript
20 lines
966 B
TypeScript
// Client-safe: imported by the tracker tag, so it carries no server code.
|
|
|
|
/**
|
|
* Where the browser's Umami tracker sends its events, relative to the app.
|
|
*
|
|
* The tracker posts to `${data-host-url}${collectPath}`, and the collect
|
|
* path is compiled into the operator's tracker build: `/api/send` by
|
|
* default, anything at all when the Umami instance sets
|
|
* `COLLECT_API_ENDPOINT` (a common ad-blocker workaround). Pointing
|
|
* `data-host-url` at the app origin therefore only worked for default
|
|
* builds; a renamed endpoint posted every page view to an app path that did
|
|
* not exist. Every path under this prefix is answered by the one proxy route
|
|
* (`src/app/api/monitoring/umami/[...path]/route.ts`), so whatever the build
|
|
* calls its endpoint, the request lands somewhere that forwards it.
|
|
*/
|
|
export const UMAMI_PROXY_PREFIX = "/api/monitoring/umami";
|
|
|
|
/** Umami's own default collect endpoint. */
|
|
export const UMAMI_DEFAULT_COLLECT_PATH = "/api/send";
|