MCPcopy Index your code
hub / github.com/TanStack/ai / fetch

Function fetch

examples/sandbox-cloudflare/src/server.ts:42–59  ·  view source on GitHub ↗
(request, env, ctx)

Source from the content-addressed store, hash-verified

40
41export default {
42 async fetch(request, env, ctx) {
43 // 1. Sandbox preview-port traffic is routed by hostname, so it gets first
44 // refusal on every request before any path-based routing.
45 const proxied = await proxyToSandbox(request, env)
46 if (proxied) return proxied
47
48 // 2. The agent's own HTTP surface. `agent.worker` is built by the package's
49 // `createSandboxAgentWorker`, so its `fetch` is always present.
50 const { pathname } = new URL(request.url)
51 if (ownedByAgent(pathname) && agent.worker.fetch) {
52 return agent.worker.fetch(request, env, ctx)
53 }
54
55 // 3. The TanStack Start app (UI + `/api/*` server routes). Start's handler
56 // takes the request (its 2nd arg is an SSR-context option, not the Worker
57 // env); bindings are read ambiently via the Cloudflare Vite plugin.
58 return handler.fetch(request)
59 },
60} satisfies ExportedHandler<AppEnv>

Callers 15

buildRequestFunction · 0.50
buildRequestFunction · 0.50
mainFunction · 0.50
useEventDispatchFunction · 0.50
initDashboardFunction · 0.50
BankingDemoPageFunction · 0.50
ProductDemoPageFunction · 0.50
CodeModePageFunction · 0.50
DashboardDemoPageFunction · 0.50
StructuredOutputPageFunction · 0.50
DatabaseDemoPageFunction · 0.50

Calls 2

ownedByAgentFunction · 0.85
fetchMethod · 0.65

Tested by

no test coverage detected