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

Function handler

apps/sim/app/ingest/[[...path]]/route.ts:37–67  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

35}
36
37async function handler(request: NextRequest) {
38 const { url, hostname } = buildTargetUrl(request.nextUrl.pathname, request.nextUrl.search)
39 const headers = buildHeaders(request, hostname)
40
41 const hasBody = !['GET', 'HEAD'].includes(request.method)
42
43 try {
44 const response = await fetch(url, {
45 method: request.method,
46 headers,
47 ...(hasBody ? { body: request.body, duplex: 'half' } : {}),
48 } as RequestInit)
49
50 const responseHeaders = new Headers(response.headers)
51 responseHeaders.delete('content-encoding')
52 responseHeaders.delete('content-length')
53 responseHeaders.delete('transfer-encoding')
54
55 return new NextResponse(response.body, {
56 status: response.status,
57 headers: responseHeaders,
58 })
59 } catch (error) {
60 logger.error('PostHog proxy error', {
61 url,
62 method: request.method,
63 error: toError(error).message,
64 })
65 return new NextResponse(null, { status: 502 })
66 }
67}
68
69export const GET = handler
70export const POST = handler

Callers 15

createMockSocketFunction · 0.50
withRouteHandlerFunction · 0.50
runHandlerWithTimeoutFunction · 0.50
runStreamLoopFunction · 0.50
executeToolFunction · 0.50
publishFunction · 0.50
withMcpAuthFunction · 0.50
constructorMethod · 0.50
handleBrokerMessageFunction · 0.50
readStructMethod · 0.50

Calls 5

toErrorFunction · 0.90
buildTargetUrlFunction · 0.85
errorMethod · 0.80
buildHeadersFunction · 0.70
deleteMethod · 0.65

Tested by 1

publishFunction · 0.40