22 lines · 1.1 KB · TypeScript
RawDownload
// ---------------------------------------------------------------------------// PostHog reverse proxy — the browser SDK targets a build-randomized// first-party path and we forward to PostHog's ingest + asset hosts. Keeps// events flowing past adblockers that match *.posthog.com. See// https://posthog.com/docs/advanced/proxy/cloudflare//// The matching and forwarding live in `./passthrough`, which server.ts// dispatches BEFORE Start loads (a proxy must not pay for the server graph).// This middleware stays registered so hosts that reach Start by another entry// keep identical behavior; in the deployed Worker it is unreachable.// --------------------------------------------------------------------------- import { createMiddleware } from "@tanstack/react-start"; import { buildPosthogUpstream, isPosthogPath } from "./passthrough"; export const posthogProxyMiddleware = createMiddleware({ type: "request" }).server(  ({ pathname, request, next }) => {    if (!isPosthogPath(pathname)) return next();    return fetch(buildPosthogUpstream(request, pathname));  },);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t