payload-posthog

Reverse Proxy

Route PostHog ingestion through your own domain.

payloadPosthog({
  apiKey: process.env.POSTHOG_API_KEY!,
  proxy: {
    path: '/ingest', // default
  },
})

Then point posthog-js at the same origin:

payloadPosthog({
  apiKey: process.env.POSTHOG_API_KEY!,
  proxy: true,
  client: {
    posthogOptions: { api_host: '/ingest' },
  },
})

This registers a root-level endpoint that forwards ingestion requests (and static assets, under /ingest/static/*) to your configured PostHog host, so requests are made same-origin instead of to *.posthog.com — less likely to be intercepted by tracking blockers. See PostHog's reverse proxy docs for the general rationale.

proxy is opt-in (default false) since it changes what your server forwards traffic to; review the security implications for your setup before enabling it in production.