Skip to content

Set up PostHog reverse proxy for docs site#1510

Draft
samseely wants to merge 1 commit into
mainfrom
cursor/posthog-reverse-proxy-d0e0
Draft

Set up PostHog reverse proxy for docs site#1510
samseely wants to merge 1 commit into
mainfrom
cursor/posthog-reverse-proxy-d0e0

Conversation

@samseely

Copy link
Copy Markdown
Contributor

Description

This PR sets up a PostHog reverse proxy for the docs site to prevent ad blockers from blocking PostHog tracking requests. The docs site was sending PostHog events directly to https://us.i.posthog.com, which is on default ad-blocker blocklists. Since the docs audience is primarily developers who commonly use ad blockers, this was causing significant underreporting of pageviews.

Changes made:

  1. Added Next.js rewrites in next.config.js to proxy PostHog traffic through first-party paths:

    • /ingest/static/:path*https://us-assets.i.posthog.com/static/:path* (for static assets)
    • /ingest/:path*https://us.i.posthog.com/:path* (for API requests)
    • /ingest/decidehttps://us.i.posthog.com/decide (for feature flag/decide endpoint)
  2. Updated lib/posthog.ts to use the proxied paths:

    • api_host: "/ingest" (routes through the local proxy)
    • ui_host: "https://us.posthog.com" (for toolbar and session recording links)

This follows PostHog's official Next.js reverse proxy documentation.

Screenshots

Network requests showing PostHog traffic routing through the /ingest proxy path instead of external PostHog domains:

Network tab showing PostHog requests going through the /ingest proxy

To show artifacts inline, enable in settings.

Linear Issue: KNO-13949

Open in Web Open in Cursor 

- Add Next.js rewrites in next.config.js to proxy /ingest/* and /ingest/static/*
  to PostHog's us.i.posthog.com and us-assets.i.posthog.com endpoints
- Update lib/posthog.ts to use /ingest as api_host and https://us.posthog.com as ui_host
- This prevents ad blockers from blocking PostHog pageview tracking by routing
  requests through the docs site's own domain

Resolves KNO-13949

Co-authored-by: Sam Seely <samseely@gmail.com>
@linear-code

linear-code Bot commented Jun 28, 2026

Copy link
Copy Markdown

KNO-13949

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 28, 2026 1:44am

Request Review

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.

2 participants