Skip to content

fix: allow reo's third-party tracking scripts and stop prefetching the home mark - #432

Open
Jesswinters wants to merge 2 commits into
mainfrom
vigilante/reo-csp-and-home-link-prefetch
Open

Jesswinters wants to merge 2 commits into
mainfrom
vigilante/reo-csp-and-home-link-prefetch

Conversation

@Jesswinters

Copy link
Copy Markdown
Collaborator

Needs security sign-off (Lisa or JD): this adds two third-party script origins to the public docs policy. They apply only with DOCS_ANALYTICS on, like the rest of ANALYTICS_SCRIPT_ORIGINS.

Merge order

Either order. The coder.com side is coder/coder-site#114, which adds the same hosts to the site's policy. On coder.com that policy replaces the router's for /docs. This PR keeps the router's own policy matching it.

Summary

This fixes two console errors every reader sees on coder.com/docs. Reo's tracking scripts are refused by the policy, and the "Coder home" mark in the icon bar makes Next prefetch coder.com's home page as if it were a docs page, which returns 404 on /__next._tree.txt.

Fix

CSP (fix(docs-config)). Reo's tag has third-party tracking turned on. It loads the Sitelytics pixel from cdn.sitelytics.tech, which then loads Sovrn's pixel from pxdrop.lijit.com. Both are now in ANALYTICS_SCRIPT_ORIGINS. Their beacons, Sovrn's iframe and aqfer.lijit.com (loaded inside that iframe) need no entry, because the policy sets only script-src. Marketing hasn't yet confirmed they use Reo's third-party tracking. If they turn it off in Reo instead, this commit can be reverted.

Home mark prefetch (fix(docs-next)). homeLinkItem sets external: false so the mark opens in the same tab, and that makes Fumadocs render it with Next's Link. On coder.com the docs and the main site share an origin, so Next treats https://coder.com/ as a page of the docs app and prefetches it. DocsProvider now passes Fumadocs a framework Link (components.Link, Fumadocs' own extension point) that renders a full URL as a plain anchor and keeps Next's Link for paths. Fumadocs already renders full URLs it treats as external as plain anchors (with target="_blank"), so only items that set external: false reach the new branch. Today that's only the home mark. Its markup, styling and same-tab behaviour are unchanged.

I tried and dropped a jsdom test that clicks the mark: under node, next/link resolves to the pages-router build with no app router mounted, so it never intercepts the click, and the test passed on the old code too. The new tests check docs-link's rendered output with a stand-in for Next's Link, plus the provider wiring.

QA

There's nothing to check on the preview. Previews leave DOCS_HOME_URL unset, so they have no home mark, and DOCS_ANALYTICS off, so they have no tags. After this deploys to production, in Chrome or Firefox:

  1. Open https://coder.com/docs/install/ with DevTools open on the Console tab, then reload. Expected: no "violates the following Content Security Policy directive" errors for cdn.sitelytics.tech or pxdrop.lijit.com.
  2. On the Network tab, filter by __next._tree. Expected: no request to https://coder.com/__next._tree.txt (requests under /docs/ are the docs' own and are fine).
  3. Click the Coder mark at the start of the icon bar at the bottom of the sidebar. Expected: coder.com's home page opens in the same tab.

Pages to compare

What to check Production Preview
Console CSP errors; __next._tree.txt 404; the home mark https://coder.com/docs/install/ Not applicable: previews have no home mark and no tags

Testing

  • Test first: docs-link.test.tsx failed (no module) before the change. pnpm test passes in docs-next (515) and docs-config (112), and the router tests pass. pnpm typecheck passes (19 tasks). pnpm lint passes, and the pre-commit hook ran on both commits.
  • Static export of the fixture corpus with DOCS_BASE_PATH=/docs and DOCS_HOME_URL set to the serving origin, loaded in Chromium. On main, the page requested / outside /docs, which is Next's prefetch of the home mark. On this branch it requested nothing outside /docs, and clicking the mark did a full page load to the main site.
  • CSP: on live coder.com, with these hosts added to the live policy, Playwright logged 0 violations on /docs and /docs/install. With the live policy as is, both pages logged the cdn.sitelytics.tech and then pxdrop.lijit.com refusals. I found the chain by recording call stacks on script insertion, which point to static.reo.dev/…/reo.js.

Upstream

No. Fumadocs works as documented: external: false means an app link. The prefetch comes from our setup, where the docs app and the main site share an origin.

🤖 This PR was generated by Coder Agents on behalf of @Jesswinters.


🤖 Built with AI assistance.

Reo's tag on coder.com has third-party tracking on. It loads the Sitelytics pixel from cdn.sitelytics.tech, which loads Sovrn's pixel from pxdrop.lijit.com, and the docs policy refused both on every page. Their beacons and Sovrn's iframe need no entry, since the policy sets only script-src. coder.com's site policy gets the same hosts in coder/coder-site.

Assisted-by: AI
The icon bar's Coder home mark is a fumadocs link item with external set to false, so it renders through Next's Link. On coder.com the docs and the main site share an origin, so Next treats https://coder.com/ as a page of the docs app and prefetches it, which answers 404 for /__next._tree.txt in every reader's console. DocsProvider now gives fumadocs a framework link that renders a full URL as a plain anchor and keeps Next's Link for paths. Fumadocs already renders full URLs it marks external as plain anchors, so only items that opt out reach this branch.

Assisted-by: AI
@Jesswinters Jesswinters self-assigned this Dec 4, 2026
@Jesswinters
Jesswinters requested review from Lisa-Fiander and nickvigilante and removed request for nickvigilante December 4, 2026 18:43
@Jesswinters
Jesswinters marked this pull request as ready for review December 4, 2026 18:44
@Jesswinters
Jesswinters requested a review from a team as a code owner December 4, 2026 18:44

This branch is waiting to be deployed

1 waiting deployment
docs-preview — f7a5efe9 Waiting Dec 4, 2026 by Jesswinters via preview / deploy preview #159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant