diff --git a/.changeset/insights-canonical-url.md b/.changeset/insights-canonical-url.md new file mode 100644 index 000000000..c55a29a68 --- /dev/null +++ b/.changeset/insights-canonical-url.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Track server-side Insights events (markdown, llms.txt, RSS, ask) with the site's public URL instead of the proxy URL. diff --git a/packages/gitbook/src/middleware.ts b/packages/gitbook/src/middleware.ts index 2edee662f..08dcf66c2 100644 --- a/packages/gitbook/src/middleware.ts +++ b/packages/gitbook/src/middleware.ts @@ -508,7 +508,8 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) { siteId: siteURLData.site, events, request: { - url: siteRequestURL.toString(), + // A proxied site's request URL is the proxy's (`/sites/site_xxx/...`), not its public one. + url: siteCanonicalURL.toString(), headers: requestHeaders, }, })