* Builds the target PostHog URL from the incoming request path. * Routes /ingest/static/* to the asset host, everything else to the API host.
(pathname: string, search: string)
| 12 | * Routes /ingest/static/* to the asset host, everything else to the API host. |
| 13 | */ |
| 14 | function buildTargetUrl(pathname: string, search: string): { url: string; hostname: string } { |
| 15 | const strippedPath = pathname.replace(/^\/ingest/, '') |
| 16 | const hostname = strippedPath.startsWith('/static/') ? ASSET_HOST : API_HOST |
| 17 | return { |
| 18 | url: `https://${hostname}${strippedPath}${search}`, |
| 19 | hostname, |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Builds forwarding headers for the PostHog request. |