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

Function startStaticServer

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

Source from the content-addressed store, hash-verified

409}
410
411function startStaticServer(config) {
412 // Reuse `vitePort` as the upstream port name so the ingress route table
413 // below stays identical to dev-with-automation.mjs.
414 logService("static", `Starting on port ${config.vitePort}...`, c.magenta);
415
416 // Mirror the proxy targets that vite.config.ts exposes in dev mode so that
417 // hitting :3001 directly behaves like Vite's dev server (e.g. /server_info
418 // is forwarded to the agent-server instead of falling back to the SPA
419 // shell). Without this, /server_info on :3001 returns index.html.
420 const staticServerScript = join(projectRoot, "scripts", "static-server.mjs");
421 const runtimeServicesInfo = JSON.stringify(
422 buildAutomationRuntimeServicesInfo({
423 ...config,
424 frontendKind: "static",
425 }),
426 );
427 spawnService(
428 "static",
429 "node",
430 [
431 staticServerScript,
432 "--dir",
433 join(config.canvasPath, "build"),
434 "--port",
435 String(config.vitePort),
436 ...(process.env.VITE_BASE_PATH
437 ? ["--base-path", process.env.VITE_BASE_PATH]
438 : []),
439 // Inject the API key so the pre-built frontend can authenticate
440 // to the agent-server without a baked-in VITE_SESSION_API_KEY.
441 ...(config.sessionApiKey
442 ? ["--session-api-key", config.sessionApiKey]
443 : []),
444 "--runtime-services-info",
445 runtimeServicesInfo,
446 ...buildLocalServiceRouteArgs(config),
447 ],
448 {
449 cwd: config.canvasPath,
450 color: c.magenta,
451 },
452 );
453}
454
455function startIngress(config) {
456 logService("ingress", `Starting on port ${config.ingressPort}...`, c.yellow);

Callers 6

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

Calls 4

logServiceFunction · 0.70
spawnServiceFunction · 0.70

Tested by 4

startServerFunction · 0.72
startServerLockedToCloudFunction · 0.72
startServerWithKeyFunction · 0.72