From 552538a0d9b22cf38891400f0ba7d9253d0cecce Mon Sep 17 00:00:00 2001 From: "Nolann B." <100787331+nolannbiron@users.noreply.github.com> Date: Wed, 7 Oct 2026 11:53:03 +0200 Subject: [PATCH] Record proxied sites' markdown, llms.txt and RSS requests under their public URL (#4660) --- .changeset/insights-canonical-url.md | 5 +++++ packages/gitbook/src/middleware.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/insights-canonical-url.md 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, }, })