MCPcopy
hub / github.com/simstudioai/sim / buildTargetUrl

Function buildTargetUrl

apps/sim/app/ingest/[[...path]]/route.ts:14–21  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

12 * Routes /ingest/static/* to the asset host, everything else to the API host.
13 */
14function 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.

Callers 1

handlerFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected