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

Function startStaticServer

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

Source from the content-addressed store, hash-verified

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

Callers 6

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

Calls 2

logServiceFunction · 0.70
spawnServiceFunction · 0.70

Tested by 4

startServerFunction · 0.72
startServerLockedToCloudFunction · 0.72
startServerWithKeyFunction · 0.72