MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / startStaticServer

Function startStaticServer

scripts/dev-static.mjs:373–434  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

371}
372
373function startStaticServer(config) {
374 // Reuse `vitePort` as the upstream port name so the ingress route table
375 // below stays identical to dev-with-automation.mjs.
376 logService("static", `Starting on port ${config.vitePort}...`, c.magenta);
377
378 // Mirror the proxy targets that vite.config.ts exposes in dev mode so that
379 // hitting :3001 directly behaves like Vite's dev server (e.g. /server_info
380 // is forwarded to the agent-server instead of falling back to the SPA
381 // shell). Without this, /server_info on :3001 returns index.html.
382 const staticServerScript = join(projectRoot, "scripts", "static-server.mjs");
383 const runtimeServicesInfo = JSON.stringify(
384 buildAutomationRuntimeServicesInfo({
385 ...config,
386 frontendKind: "static",
387 }),
388 );
389 spawnService(
390 "static",
391 "node",
392 [
393 staticServerScript,
394 "--dir",
395 join(config.canvasPath, "build"),
396 "--port",
397 String(config.vitePort),
398 ...(process.env.VITE_BASE_PATH
399 ? ["--base-path", process.env.VITE_BASE_PATH]
400 : []),
401 // Inject the API key so the pre-built frontend can authenticate
402 // to the agent-server without a baked-in VITE_SESSION_API_KEY.
403 ...(config.sessionApiKey
404 ? ["--session-api-key", config.sessionApiKey]
405 : []),
406 "--runtime-services-info",
407 runtimeServicesInfo,
408 "--route",
409 `/api/automation=http://localhost:${config.autoBackendPort}`,
410 "--route",
411 `/api=http://localhost:${config.agentServerPort}`,
412 "--route",
413 `/sockets=http://localhost:${config.agentServerPort}`,
414 "--route",
415 `/server_info=http://localhost:${config.agentServerPort}`,
416 "--route",
417 `/health=http://localhost:${config.agentServerPort}`,
418 "--route",
419 `/ready=http://localhost:${config.agentServerPort}`,
420 "--route",
421 `/alive=http://localhost:${config.agentServerPort}`,
422 "--route",
423 `/docs=http://localhost:${config.agentServerPort}`,
424 "--route",
425 `/redoc=http://localhost:${config.agentServerPort}`,
426 "--route",
427 `/openapi.json=http://localhost:${config.agentServerPort}`,
428 ],
429 {
430 cwd: config.canvasPath,

Callers 6

startServerFunction · 0.90
startServerLockedToCloudFunction · 0.90
startServerWithKeyFunction · 0.90
mainFunction · 0.70

Calls 3

logServiceFunction · 0.70
spawnServiceFunction · 0.70

Tested by 4

startServerFunction · 0.72
startServerLockedToCloudFunction · 0.72
startServerWithKeyFunction · 0.72